Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 how to Read folder contents

Author  Topic 

salmonraju
Yak Posting Veteran

54 Posts

Posted - 2007-08-13 : 02:15:52
Hi,

I am creating a windows application,that contains a folder,with 5 files. how to programaticlly get the names of all the files in that folder(getting names of all the contents of that folder)

Say folder name is "MyXMLFolder" .It contains elemnts as
-Customer.xml
-Employee.Xml
-Bank.xml

I want c# coding to get all the names of the files in "MyXMLFolder" folder

chrisrock
Starting Member

12 Posts

Posted - 2007-08-13 : 13:45:05
string[] files = System.IO.Directory.GetFiles(Server.MapPath("~/MyXmlFolder"));

foreach(string file in files)
{
Response.Write(string.Format("{0}<br>", file));
// you can also use System.IO.Path.GetFileName(file) to get just the file name

}
Go to Top of Page
   

- Advertisement -