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" );
}
}
}
}
 

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

Back
Top