Get files in a folder

Viewed 48240

In my MVC application I have the following paths;

  • /content/images/full
  • /content/images/thumbs

How would I, in my c# controller, get a list of all the files within my thumbs folder?

Edit

Is Server.MapPath still the best way?

I have this now DirectoryInfo di = new DirectoryInfo(Server.MapPath("/content/images/thumbs") ); but feel it's not the right way.

is there a best practice in MVC for this or is the above still correct?

2 Answers
Directory.GetFiles("/content/images/thumbs")

That will get all the files in a directory into a string array.

Related