Access Network path c#.

Posted by Toashish80 under C# on 2/21/2011 | Points: 10 | Views : 15205 | Status : [Member] | Replies : 3
I have some files available on a network path. The network path could probably be as "\\ServeName\foldername\". I want the list of files under this path in my windows application.

Can anybody help me on this.




Responses

Posted by: Madhu.b.rokkam on: 2/21/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
DirectoryInfo dirInfo = new DirectoryInfo("Your Path");
foreach(FileInfo file in dirInfo.GetFiles())
{
lstbox.items.add(file.Name);
}

Thanks and Regards
Madhu

Toashish80, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 2/21/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Try this

DirectoryInfo di = new DirectoryInfo("c:/inetpub/wwwroot/demos");

FileInfo[] rgFiles = di.GetFiles("*.aspx");
foreach(FileInfo fi in rgFiles)
{
// DO wot ever you want with the file
}


Thanks
Karthik
www.f5Debug.net

Toashish80, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: T.saravanan on: 2/21/2011 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi,

Try this code...
// If get a file from Network means just add double slash in front of the path.
DirectoryInfo dir = new DirectoryInfo("\\\\NetworkPath\\TestData\\");  

foreach(FileInfo fi in dir.GetFiles())
{
Console.WriteLine(fi.Name);
}
Console.Read();


Cheers :)

Thanks,
T.Saravanan

Toashish80, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response