1

I have a remote host \\foo that serves up shares: \\foo\a, \\foo\b, and \\foo\c

On my local Win 7 client machine, when I bring up Windows Explorer and enter \\foo in the address bar, it obliges me by showing the names of the 3 shares. The Type attribute for each is "Share"

I have a C# program and I want it to mimic Windows Explorer. I have a method that accepts what should be the a local path name (e.g., C:\x\y\z), fully-qualified share name (e.g., \\foo\a), or host name (e.g., \\foo). The method is to get the names of the items (folder, share, file, 1st level only) contained within the folder, share, or host, just like Windows explorer

File.Exists("\\foo") and Directory.Exists("\\foo") both return false

new DirectoryInfo("\\foo") and File.GetAttributes("\\foo") throw an exception "The UNC path should be of the form \server\share"

The Path class seems designed to return just strings and not attributes

Given only the string "\\foo", is there a class method/property that will identify it as a host or at least let me test it to see if it is a host and then obtain a list of names that are its children?

VA systems engineer
  • 2,856
  • 2
  • 14
  • 38
  • Have you tested to make sure it's actually reading it like a directory? i.e ``\\foo\`` – Jaskier Dec 04 '19 at 19:46
  • 1
    when you say "it's", I assume you mean my C# program. It's not reading it like a directory. `Directory.Exists("\\foo")` returns false. This makes sense because it's not a directory. It's a host name, hence my question: `How to identify \\hostName as a host and obtain the names of child items under \\hostName?` – VA systems engineer Dec 05 '19 at 12:53
  • Yes, it answered my question – VA systems engineer Dec 05 '19 at 19:53

0 Answers0