473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Detecting whether the Path is local or remote

Hello,
I'm trying to find out a way to detect whether a path passed resides locally
or on a remote machine.

I can easily detect a path like \\machinename\path to be remote. But when it
comes to a mapped path, I don't really know what to do about it.

Does anyone have any idea how to do this?
Nov 15 '05 #1
2 4490
It will require some pInvoke work but, I recommend looking into the
GetDriveType() API function call. It should give you just what you want.

DL
"Hayato Iriumi" <hi*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hello,
I'm trying to find out a way to detect whether a path passed resides locally or on a remote machine.

I can easily detect a path like \\machinename\path to be remote. But when it comes to a mapped path, I don't really know what to do about it.

Does anyone have any idea how to do this?

Nov 15 '05 #2
I found a better one.

Here it is.

class Class1
{
[DllImport("shlwapi.dll")]
private static extern bool PathIsNetworkPath(string
Path);

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
string strPath = "D:\\Temp";
bool blnIsLocalPath = IsLocalPath(strPath);
Console.WriteLine(blnIsLocalPath.ToString());
Console.ReadLine();

}

private static bool IsLocalPath(string Path)
{
return !PathIsNetworkPath(Path);
}
}
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: wireless200 | last post by:
I'm running EM on my local box and sql server on a remote internet accessed box. How do I specify a file path for a DTS package to access files on the remote box? For example, to run a local...
1
by: Steve | last post by:
Hi all, I am referring to this article in MSDN : http://msdn.microsoft.com/library/en-us/secauthn/security/logonuser.asp While creating folder on the remote machine, we are specifying the UNC...
10
by: Jeff Grantham | last post by:
I have the code below and it does what i want except for one thing and I can't for the life of me figure it out. It makes multiple copies of the entries in the Event Log and sends multiple emails....
2
by: enrique | last post by:
Hello everyone, I'm looking for a "directory path" solution that will allows me to test my app locally and then test on remote web server without having to update my web.config file each time I...
9
by: larrybud2002 | last post by:
I've read about this error in this group and others from early 2006 but without any resolution, so I thought I'd bump it up to see if there's a solution. Trying to build a website on ...
8
SqUiMbO
by: SqUiMbO | last post by:
I have been searching and searching for a way to detect whether or not the user who launched my application is a local user or someone that is "remoted" in. This sounds like a very simple thing to...
5
by: NeBlackCat (lists) | last post by:
Hello everybody - my first post! And it may be the most monumentally stupid question ever asked, but I just can't see an answer after several hours experimenting, searching and reading. It's...
4
by: Vlad | last post by:
I am having problems using the file.create method within a function that is called when looping through an array of filepaths. If I call my function with a hardcoded file path --C:\Temp.txt the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.