0

I have created an Asp.net application.

It contains a folder called PDF and a folder called Requirement just beneath that.

I have a link in another page called Requirement.

If i click on that link i need to find all the files in the folder PDF/Requirement.

Kenny Evitt
  • 9,291
  • 5
  • 65
  • 93
Pradeep
  • 4,612
  • 10
  • 38
  • 50
  • Do you know `System.IO.File` and `System.IO.Directory`? – PedroC88 Apr 07 '12 at 15:22
  • 1
    You can google for this and get your answer in under 1 minute. – Sergey Akopov Apr 07 '12 at 15:22
  • I get only string "/pdf/Requirement". I need to append application path along with above. How can i do that ? – Pradeep Apr 07 '12 at 15:27
  • I tried Request.ApplicationPath. But return only root application Folder name, not all path where that folder exists ? – Pradeep Apr 07 '12 at 15:29
  • i got answer Request.PhysicalApplicationPath. – Pradeep Apr 07 '12 at 15:41
  • 2
    You can use Server.MapPath("~/pdf/requirement") to get the full path. Tilda char means get the path relative to the application root (which might not coincide with the website's root, since in a website you can have other applications) – Adrian Iftode Apr 07 '12 at 17:04
  • In the future, please breakup your questions into sub-questions, recursively as needed, so that you eventually end up with *specific*, *concrete* problems. As-is, you've clarified that you really had several problems. – Kenny Evitt May 15 '14 at 16:41

2 Answers2

0
var getFileName = Directory.GetFiles(Server.MapPath("~/PDF/Requirement"));  // Collection Of file name with extention.

var getFileNameExcludeSomeExtension1 = from f in Directory.GetFiles(Server.MapPath("~/PDF/Requirement"))
                                       where Path.GetExtension(f) != ".scc" && Path.GetExtension(f) != ".db"
                                       select Path.GetFileNameWithoutExtension(f);   // Collection Of file name with extention and filtering.

var getFileNameExcludeSomeExtension2 = from f in Directory.GetFiles(Server.MapPath("~/PDF/Requirement"))
                                       where Path.GetExtension(f) != ".scc" && Path.GetExtension(f) != ".db"
                                       select Path.GetFileName(f);   // Collection Of file name with out extention and filtering.
Thulasiram
  • 8,432
  • 8
  • 46
  • 54
0

I suggest to use EnumerateFiles as this Regex to find a file in folder and if you tried GetFiles dont because of performance you could see difference in this What is the difference between Directory.EnumerateFiles vs Directory.GetFiles?

Community
  • 1
  • 1
QMaster
  • 3,743
  • 3
  • 43
  • 56