Is it a mapped network drive ?

G

Guest

Given a full path (C:\Dir1\Dir2\... or \\host\dir1\dir1 etc.), How can I
tell if the root drive of the path is a local drive or mapped network drive?
 
N

Nicholas Paldino [.NET/C# MVP]

Sharon,

Use the DriveInfo class in the System.IO namespace. You can pass the
drive letter to the constructor. Then, check the DriveType property to see
if it equals DriveType.Network.

Hope this helps.
 
G

Guest

I think the System.IO.DriveInfo class exists only in the .NET 2.0, but I'm
using the 1.1 version.
Am I right?

For now I'm using the corresponding Win32 API function GetDriveType() in the
kernel32.dll and it works nicely.
 
K

Kevin Yu [MSFT]

Hi Sharon,

Yes, System.IO.DriveInfo class only exists in .NET framework 2.0. In 1.1,
the only workaround is to use PInvoke to call GetDriveType() function.

Kevin Yu
Microsoft Online Community Support

============================================================================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
============================================================================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
M

Martin Carpella

Nicholas Paldino said:
Sharon,

Use the DriveInfo class in the System.IO namespace. You can pass the
drive letter to the constructor. Then, check the DriveType property to see
if it equals DriveType.Network.

Even in .NET 2.0, it seems that DriveInfo is unable to handle mount
points at all. Or am I missing something?

Best regards,
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top