Nicholas,
Thanks a lot for the help. However, I think you misunderstood my problem (I
mean I was not clear...).
I went to the site you mentioned and have made a small test program to make
sure it does what I'm looking for:
string myUnc = GetUniversalName(@"c:\temp");
if (myUnc != null)
Console.WriteLine(@"share for c:\temp is {0}", myUnc);
else
Console.WriteLine(@"No share found for c:\temp");
By applying this code, I always get this error "This network connection does
not exist".
Reading the documentation of WNetGetUniversalName, I understand the meaning
of the error.
I'm passing a local drive that does not map to a network ressource (it is a
local drive).
What I'm trying to get is really the UNC name of a directory of one of my
local drives.
Thanks,
José
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:uq**************@TK2MSFTNGP09.phx.gbl...
Arlid,
What about the WNetGetNetworkShare API function?
To the OP, check out the WNetGetUniversalName definition on
http://www.pinvoke.net. I've included a wrapper function which will set
up the buffers and extract the string from the structure passed to the API.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Arild Bakken" <ar*****@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...I guess you'll need to enumerate the shares on the computer and see if
anyof them refer to the given path. Take a look at the Win32_Share WMI class
and the System.Management namespace.
Arild
"José Joye" <jo*******@KILLTHESPAMSbluewin.ch> wrote in message
news:%2***************@tk2msftngp13.phx.gbl... Hello,
Can someone could help me with the following:
I have a directory (e.g.: C:\myTest) and I want to retrieve the UNC
share name that has been assigned to it (or null if no share is defined for
this
particular directory).
My first guess was to look at the DirectoryInfo Class. However, I could
not
find anything.
Any help welcome!
José