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
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Micke BlomqvistPosted Mar 22, 2011, 9:43 AM
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
}