I need the webpage to display the list of filenames from a directory in the server. The Directory.GetFiles() doesn't accept the uri http://192......./...
Please assist me to solve my problem as early as possible
Thanks,
FAAS
List filenames from a directory in the server
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Micke BlomqvistRank #1,660 · 923 reputationPosted Mar 22, 2011, 5:43 AM EDT
The GetFiles method takes a filepath as a parameter, so make sure the IIS account has the right authority to access the files and the give the local path to the files. For example:
foreach(string file in System.IO.Directory.GetFiles(@"c:\files_folder_path"))
{
// Do what you need listing the files
}
or, if the files are in the application directory of your webapplication:
(for example in the documents folder)
foreach(string file in System.IO.Directory.GetFiles(Server.MapPath("documents")))
{
// Do what you need listing the files
}