Determining if a path is a network path (aka mapped drive - PathIsNetworkPath)

  • Thread starter Thread starter Robert Munroe
  • Start date Start date
R

Robert Munroe

I am posting this because I couldn't find anything on the subject on
Usenet. Thanks to my good friend Oliver for the tip! Tested and
works on XP Pro.


using System;
using System.Runtime.InteropServices;

namespace NetPathTest
{
class NetPath {
[DllImport("shlwapi.dll")]
public static extern bool PathIsNetworkPath(string path);
}

class Testing
{
[STAThread]
static void Main(string[] args)
{
string mydrive = @"I:\";

if (NetPath.PathIsNetworkPath( mydrive ) == true) {
Console.WriteLine( mydrive + " is a mapped drive" );
}
}
}
}
 
Back
Top