RE: How do I enumerate available drives.

From: Ssmoimo (Ssmoimo_at_discussions.microsoft.com)
Date: 01/12/05


Date: Wed, 12 Jan 2005 15:37:04 -0800


"Phillip N Rounds" wrote:

> 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
>
>
>



Relevant Pages

  • RE: How do I enumerate available drives.
    ... > and then of course the directory tree, ... how to I enumerate all the available drives? ...
    (microsoft.public.dotnet.framework.windowsforms)
  • RE: How do I enumerate available drives.
    ... To enumerate the drives you can use... ... "Phillip N Rounds" wrote: ... > and then of course the directory tree, ...
    (microsoft.public.dotnet.languages.vc)
  • RE: How do I enumerate available drives.
    ... To enumerate the drives you can use... ... "Phillip N Rounds" wrote: ... > and then of course the directory tree, ...
    (microsoft.public.dotnet.framework.windowsforms)
  • RE: Windows Explorer and Media player query
    ... The directory tree in the left pane of explorer only shows the drives ... drives are no longer displayed and I have to click MC again to display them. ...
    (microsoft.public.windowsxp.basics)
  • Enumerating files in an UNC folder in Delphi 5, how ??
    ... I have tried several components available for D5 to enumerate ... UNC-folders which are not mounted as drives on the computer, ... deduce the UNC path from a mounted disk and file, ... program in .NEt technology ?? ...
    (comp.lang.pascal.delphi.misc)