Dir Search On Server
-
Hiya Does anyone know how to search for all directories on the C:\\ for a server?? I have a web server on a remote machine and need to list certain directories on that machine. I do have full permissions to the machine. Have tried this: foreach (string d in Directory.GetDirectories("\\ip address\\C:\\")) { MessageBox.Show( d.ToString() ); } Thanks.
-
Hiya Does anyone know how to search for all directories on the C:\\ for a server?? I have a web server on a remote machine and need to list certain directories on that machine. I do have full permissions to the machine. Have tried this: foreach (string d in Directory.GetDirectories("\\ip address\\C:\\")) { MessageBox.Show( d.ToString() ); } Thanks.
You need to use the admin share, C$ (\\SERVERNAME\C#). Recursively enumerating the files will be quite slow remotely, however. You might consider - if possible - using .NET Remoting or some other remote technology to tell the server to search it's own hard drive (much faster) and report back to you the results (whether you're filtering or not, whatever fulfills your requirements).
Microsoft MVP, Visual C# My Articles
-
You need to use the admin share, C$ (\\SERVERNAME\C#). Recursively enumerating the files will be quite slow remotely, however. You might consider - if possible - using .NET Remoting or some other remote technology to tell the server to search it's own hard drive (much faster) and report back to you the results (whether you're filtering or not, whatever fulfills your requirements).
Microsoft MVP, Visual C# My Articles
Thanks for that. Only need to search for Directories not files. Will look into it.
-
You need to use the admin share, C$ (\\SERVERNAME\C#). Recursively enumerating the files will be quite slow remotely, however. You might consider - if possible - using .NET Remoting or some other remote technology to tell the server to search it's own hard drive (much faster) and report back to you the results (whether you're filtering or not, whatever fulfills your requirements).
Microsoft MVP, Visual C# My Articles
Could you actually show me how to use this while I am considering other options. Have tried: foreach (string sDir in Directory.GetDirectories("ip\\C$:\\")) { MessageBox.Show( sDir.ToString() ); }
-
Could you actually show me how to use this while I am considering other options. Have tried: foreach (string sDir in Directory.GetDirectories("ip\\C$:\\")) { MessageBox.Show( sDir.ToString() ); }
I did: \\SERVER\C$. You could also use \\IP\C$. Don't use a colon (:). That's the admin share for a drive, which Windows NT establishes for each local drive automatically. And you don't need to call
sDir.ToString
because it's already a string.foreach (string dir in Directory.GetDirectories("\\SERVER\C$"))
Console.WriteLine(dir);Microsoft MVP, Visual C# My Articles