|
-
Mar 29th, 2011, 05:53 AM
#1
Thread Starter
Addicted Member
How to tell if a file path is local or on a server?
At the moment I do not have access to a multidomain environment.
Nonetheless my application has functions and features which need to run differently if a file is stored locally or on a network.
This means that I have to determine if the files my application is working on are stored locally or on a network, so how can I do this?
A local file's path is typically something like:
C:\Folder\File.txt
A Unc path should look something like this:
\\ComputerName\Folder\File.txt
So far it seems easy, all I need to do is look for "\\" at the start of the path to identify a Unc path, and then I can extract the server name from the path if an api function needs the server name.
Although what about mapped drives? For example if E:\folder\file where E is a drive that is mapped to a server.
As some windows api calls optionally accept the server name do I need to extract it, or can I treat mapped files like local files?
+ do I need to consider other file paths formats?
All men have an inherent right to life, the right to self determination including freedom from forced or compulsory labour, a right to hold opinions and the freedom of expression, and the right to a fair trial and freedom from torture. Be aware that these rights are universal and inalienable (cannot be given, taken or otherwise transferred or removed) although you do risk losing the aforementioned rights should you fail to uphold them e.g Charles Taylor; United Nations sources: http://www.un.org/en/documents/udhr/, http://www.ohchr.org/EN/Professional...ages/CCPR.aspx. Also Charles I was beheaded on the 30th of January of 1649 for trying to replace parliamentary democracy with an absolute monarchy, the same should happen to Dr Phil and Stephen Fry; source: http://www.vbforums.com/showthread.p...ute-Monarchism.
The plural of sun is stars you Catholic turkeys.
-
Mar 29th, 2011, 07:04 AM
#2
Re: How to tell if a file path is local or on a server?
Check this page. See also the related topics at the top of the page.
http://vbnet.mvps.org/index.html?cod...slocalpath.htm
-
Mar 29th, 2011, 08:22 AM
#3
Thread Starter
Addicted Member
Re: How to tell if a file path is local or on a server?
Thanks for the link VBClassicRocks ,
This is the api which is used in the examples:
Code:
Private Declare Function PathIsNetworkPath Lib "shlwapi" _
Alias "PathIsNetworkPathA" _
(ByVal pszPath As String) As Long
and it seems to work for:
1. local paths (including relative paths)
2. mapped drives
3. UNC
4. IP address,
which is good.
I should be able to get to the server name from UNC and IP address paths, which means my only concern is how to extract the server name from a mapped drive path?
All men have an inherent right to life, the right to self determination including freedom from forced or compulsory labour, a right to hold opinions and the freedom of expression, and the right to a fair trial and freedom from torture. Be aware that these rights are universal and inalienable (cannot be given, taken or otherwise transferred or removed) although you do risk losing the aforementioned rights should you fail to uphold them e.g Charles Taylor; United Nations sources: http://www.un.org/en/documents/udhr/, http://www.ohchr.org/EN/Professional...ages/CCPR.aspx. Also Charles I was beheaded on the 30th of January of 1649 for trying to replace parliamentary democracy with an absolute monarchy, the same should happen to Dr Phil and Stephen Fry; source: http://www.vbforums.com/showthread.p...ute-Monarchism.
The plural of sun is stars you Catholic turkeys.
-
Mar 29th, 2011, 08:30 AM
#4
Re: How to tell if a file path is local or on a server?
 Originally Posted by Witis
... my only concern is how to extract the server name from a mapped drive path?
Try this http://support.microsoft.com/kb/192689
-
Mar 29th, 2011, 08:37 AM
#5
Thread Starter
Addicted Member
Re: How to tell if a file path is local or on a server?
thanks again LaVolpe, that code looks good so I'll write it in and test it later. rgds
All men have an inherent right to life, the right to self determination including freedom from forced or compulsory labour, a right to hold opinions and the freedom of expression, and the right to a fair trial and freedom from torture. Be aware that these rights are universal and inalienable (cannot be given, taken or otherwise transferred or removed) although you do risk losing the aforementioned rights should you fail to uphold them e.g Charles Taylor; United Nations sources: http://www.un.org/en/documents/udhr/, http://www.ohchr.org/EN/Professional...ages/CCPR.aspx. Also Charles I was beheaded on the 30th of January of 1649 for trying to replace parliamentary democracy with an absolute monarchy, the same should happen to Dr Phil and Stephen Fry; source: http://www.vbforums.com/showthread.p...ute-Monarchism.
The plural of sun is stars you Catholic turkeys.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|