1
Answer

list filenames from a directory in the server

faas

faas

13y
2.2k
1
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
Answers (1)
0
Micke Blomquist

Micke Blomquist

NA 1.2k 976.5k 13y
Hi,

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
}