4

I'm trying to retrieve the list of files of one directory with the following code:

string[] files = System.IO.Directory.GetFiles(source);

If i try to retrieve them from a local directory, let's say C:\SomeFolder\ The string array is created correctly. If i do this on a share (\\someshare\somefolder) the array is not created.

I have to do any aditional step to retrieve from a share?

To test I already gave "Full Control" permission to every users on this share. So I guess is not permissions related.

Thanks in advance for the help.

Andre Roque
  • 503
  • 1
  • 9
  • 31
  • 1
    Does any of the following apply? http://stackoverflow.com/questions/2352197/how-do-i-access-a-network-drive-through-the-usual-system-io-classes – Heinzi Feb 19 '16 at 16:51
  • Is the first option. I'm working on a domain that have trust relationship with the other, and my user have permissions on both – Andre Roque Feb 19 '16 at 16:53
  • @AndreRoque if you have access to that share or your application has access to that share.. then it will work.. why don't you setup a system account for your application and then from there users can run it.. is this a web application || winforms application..? if so then you have to have the IIS_USER granted permissions to that shared drive. – MethodMan Feb 19 '16 at 17:02
  • it's a Windows Forms application. There's a way to force login/password to access that share throw the application? – Andre Roque Feb 19 '16 at 17:20

2 Answers2

1

Simple question:

Have you tried your source string with @"\share\directory\folder" ?

Alternatively use source string with "\\share\directory\folder"

It worked for me....

Hope it helps someone...

ShaunOReilly
  • 2,186
  • 22
  • 34
0

There might be now files in this directory. Try below

Directory.GetFiles(path, "*", SearchOption.AllDirectories);
koprinkov
  • 71
  • 2