Home All Groups Group Topic Archive Search About

UNC paths from drive mappings

Author
2 Mar 2007 9:56 AM
JezB
I can get a list of drive mappings via

Directory.GetLogicalDrives

but is there any way I can get the UNC path (eg. \\machine\sharename) for
those drives that are mapped to network shares?

Author
2 Mar 2007 10:22 PM
Bryan Phillips
Use the DriveInfo class:

        foreach(DriveInfo drive in DriveInfo.GetDrives()){
            Console.WriteLine(drive + " " + drive.DriveType);
        }

DriveType will equal "Network" for mapped drives.

--
Bryan Phillips
MCSD, MCDBA, MCSE
Blog:  http://bphillips76.spaces.live.com



Show quote
"JezB" <j***@somewhere.com> wrote in message
news:erYwkDLXHHA.4240@TK2MSFTNGP06.phx.gbl:

> I can get a list of drive mappings via
>
> Directory.GetLogicalDrives
>
> but is there any way I can get the UNC path (eg. \\machine\sharename) for
> those drives that are mapped to network shares?
Author
5 Mar 2007 7:28 PM
Ben Voigt
"JezB" <j***@somewhere.com> wrote in message
news:erYwkDLXHHA.4240@TK2MSFTNGP06.phx.gbl...
>I can get a list of drive mappings via
>
> Directory.GetLogicalDrives
>
> but is there any way I can get the UNC path (eg. \\machine\sharename) for
> those drives that are mapped to network shares?

http://pinvoke.net/default.aspx/netapi32/NetUseEnum.html
Author
7 Mar 2007 9:01 PM
Bryan Phillips
I would avoid using p/invoke if you can, but I break this same rule when
I have to do so.

--
Bryan Phillips
MCSD, MCDBA, MCSE
Blog:  http://bphillips76.spaces.live.com



Show quote
"Ben Voigt" <rbv@nospam.nospam> wrote in message
news:OiXXqw1XHHA.1216@TK2MSFTNGP03.phx.gbl:

> "JezB" <j***@somewhere.com> wrote in message
> news:erYwkDLXHHA.4240@TK2MSFTNGP06.phx.gbl...
> >I can get a list of drive mappings via
> >
> > Directory.GetLogicalDrives
> >
> > but is there any way I can get the UNC path (eg. \\machine\sharename) for
> > those drives that are mapped to network shares?
>
> http://pinvoke.net/default.aspx/netapi32/NetUseEnum.html

AddThis Social Bookmark Button