3

I wanted to get the list of all files from a folder on my network drive.

Something like,

\\10.151.50.50\\OfficeDocs\\

In command prompt, I could do like this:

pushd \\10.151.50.50\\OfficeDocs\\

I have to get the files under the OfficeDoc through my C# program and this is my code:

var system = System.IO.Directory.GetFiles("\\10.151.50.50\\OfficeDocs");

But, I got an exception saying Could not find a part of C:\10.151.50.50\OfficeDocs

Why the network drive is been mapped to C:\\ drive and not my network location?How to get all the files under OfficeDocs which is in my network location\\10.151.50.50 ?

Anirudha
  • 32,393
  • 7
  • 68
  • 89

1 Answers1

2

Problem: you need to give double slash when you are accessing the remote machine

Try :

var system = System.IO.Directory.GetFiles("\\\\10.151.50.50\\OfficeDocs");

or

var system = System.IO.Directory.GetFiles(@"\\10.151.50.50\OfficeDocs");
Sudhakar Tillapudi
  • 25,935
  • 5
  • 37
  • 67