473,796 Members | 2,517 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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\p ath 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 4514
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*****@hotmai l.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.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\p ath 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("shlw api.dll")]
private static extern bool PathIsNetworkPa th(string
Path);

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
string strPath = "D:\\Temp";
bool blnIsLocalPath = IsLocalPath(str Path);
Console.WriteLi ne(blnIsLocalPa th.ToString());
Console.ReadLin e();

}

private static bool IsLocalPath(str ing Path)
{
return !PathIsNetworkP ath(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
2537
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 dts package the filepath is c:\filepath\file.txt. How would I change the file path/name to allow the dts package to
1
2235
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 path as per the example. But we get this error "could not find a part of the path". we are prefixing the path with @ symbol and also tried with the escaping the "\\".
10
3041
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. I would appreciate any help in figuring out what is going on. Thanks. ---- Begin Code ---- Imports System
2
2267
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 modify the file. In other words I'm storing the paths (for centralizing purposes) as custom <appSettings> in the web.config. expample (for local testing): <add key="imagePath" value="http://localhost/app_folder/10_media/images/" />
9
4016
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 http://oursite:8080/ and it returns
8
5964
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 check, but I cannot find any articles about it anywhere, nor could I find it in the Microsoft language reference. I know that is it possible, as, for example, Windows will not a "remote" user run a Direct3D app. It pops up a message saying something...
5
1935
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 simply this - how can a function determine whether or not it's being called in handling of an exception (ie. there is an "active" exception, and somewhere upstream on the stack there is an except: block statement)? Depending on what you read,...
4
6916
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 function creates the file as expected. When I loop through my array I get the error - "ArgumentException was unhandled - Illegal characters in path" The value "C:\Temp.txt" is the first value in the array - as it works
0
9684
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9530
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10236
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10017
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9055
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7552
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5445
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.