0

In other words can I simply use this to list files in smb:

if the string argument below called "sDir" is some ip of SMB share, say like "\\12.12.12.12"?

static void DirSearch(string sDir)
{
    try
    {
        foreach (string d in Directory.GetDirectories(sDir))
        {
            foreach (string f in Directory.GetFiles(d))
            {
                Console.WriteLine(f);
            }
            DirSearch(d);
        }
    }
    catch (System.Exception excpt)
    {
        Console.WriteLine(excpt.Message);
    }
}
Robert G
  • 49
  • 3
  • Why don't you just try? But the answer is yes, The Directory methods accept UNC paths. But these must stzart with a double backslash, so in your example @"\\12.12.12.12" or equivalently, "\\\\12.12.12.12" – Klaus Gütter Apr 13 '20 at 04:57
  • You can refer to [Create file , get file and delete with SMB protocol](https://stackoverflow.com/questions/40017663/create-file-get-file-and-delete-with-smb-protocol) to know how to access the file in smb. – Jack J Jun Apr 14 '20 at 07:56

0 Answers0