P
Phillip N Rounds
I need to eumerate all available drives in a C# Windows Form application (
and then of course the directory tree, but that's not the problem)
My question is, how to I enumerate all the available drives?
My initial thought was along the lines of
DirectoryInfo di = new DirectoryInfo( "c:\\");
DirectoryInfo Root = new DirectoryInfo( di.Parent.Name.ToString() );
DirectoryInfo[] RootDrives = Root.GetDirectories();
This, of course, doesn't work as the parent of c:\ is null.
For my immediate needs, I could simply loop through a:\, b:\, c:\... z:\,
test to see if the new DirectoryInfo("x:\\") threw an error, and be
satisfied with that.
This seems, at least, to be crude. I also would like the ability to get UNC
shares.
Anyone have a solution?
Thanks
Phil
and then of course the directory tree, but that's not the problem)
My question is, how to I enumerate all the available drives?
My initial thought was along the lines of
DirectoryInfo di = new DirectoryInfo( "c:\\");
DirectoryInfo Root = new DirectoryInfo( di.Parent.Name.ToString() );
DirectoryInfo[] RootDrives = Root.GetDirectories();
This, of course, doesn't work as the parent of c:\ is null.
For my immediate needs, I could simply loop through a:\, b:\, c:\... z:\,
test to see if the new DirectoryInfo("x:\\") threw an error, and be
satisfied with that.
This seems, at least, to be crude. I also would like the ability to get UNC
shares.
Anyone have a solution?
Thanks
Phil