Is it a mapped network drive ?

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
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.
 
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.
 
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.)
 
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
 
Back
Top