473,407 Members | 2,312 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,407 software developers and data experts.

Translate drive letter to UNC for mapped drives

Hi, I'm converting a C++ program over to C# (on .Net 2.0), and am not
sure of the best way to look up the UNC path for mapped drives.

The way the C++ program does this is it iterates through a listing of
drive letters, then calls WNetGetUniversalName for each to get the UNC.
.Net 2.0 seems to have a fairly broad selection of IO handling
options, but I've not yet found one to handle my problem.

Any pointers?
Aug 10 '06 #1
3 9367
Michael,

.NET doesn't have anything to handle this out of the box. However, you
can call the WNetGetUniversalName API through the P/Invoke layer if you
wish.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Michael Russell" <mr*******@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Hi, I'm converting a C++ program over to C# (on .Net 2.0), and am not sure
of the best way to look up the UNC path for mapped drives.

The way the C++ program does this is it iterates through a listing of
drive letters, then calls WNetGetUniversalName for each to get the UNC.
.Net 2.0 seems to have a fairly broad selection of IO handling options,
but I've not yet found one to handle my problem.

Any pointers?

Aug 10 '06 #2
Like Nicholas said, you should use WNetGetUniversalName. Here's a code
snippet that shows how to use P/Invoke to get the UNC path:

http://groups.google.com/group/micro...e214768a2b3b76
Nicholas Paldino [.NET/C# MVP] wrote:
Michael,

.NET doesn't have anything to handle this out of the box. However, you
can call the WNetGetUniversalName API through the P/Invoke layer if you
wish.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Michael Russell" <mr*******@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Hi, I'm converting a C++ program over to C# (on .Net 2.0), and am not sure
of the best way to look up the UNC path for mapped drives.

The way the C++ program does this is it iterates through a listing of
drive letters, then calls WNetGetUniversalName for each to get the UNC.
.Net 2.0 seems to have a fairly broad selection of IO handling options,
but I've not yet found one to handle my problem.

Any pointers?
Aug 10 '06 #3
John Duval wrote:
Like Nicholas said, you should use WNetGetUniversalName. Here's a code
snippet that shows how to use P/Invoke to get the UNC path:

http://groups.google.com/group/micro...e214768a2b3b76
Nicholas Paldino [.NET/C# MVP] wrote:
>Michael,

.NET doesn't have anything to handle this out of the box. However, you
can call the WNetGetUniversalName API through the P/Invoke layer if you
wish.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Michael Russell" <mr*******@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>>Hi, I'm converting a C++ program over to C# (on .Net 2.0), and am not sure
of the best way to look up the UNC path for mapped drives.

The way the C++ program does this is it iterates through a listing of
drive letters, then calls WNetGetUniversalName for each to get the UNC.
.Net 2.0 seems to have a fairly broad selection of IO handling options,
but I've not yet found one to handle my problem.

Any pointers?
Thanks John and Nicholas. A little disappointing that there isn't
something built-in, but I appreciate the confirmation and the link to
the code snippet.

Michael
Aug 10 '06 #4

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

Similar topics

0
by: Ben Reese | last post by:
Kind people on this discussion group have previously helped me to dynamically identify CD rom drives etc at runtime using objects in System.management +++++++++++++++++++++++++++++++++++++++ Dim...
0
by: Ben Reese | last post by:
Kind people on this discussion group have previously helped me to dynamically identify CD rom drives etc at runtime using objects in System.management +++++++++++++++++++++++++++++++++++++++ Dim...
6
by: Ricky | last post by:
My question: If I have a mapped driver letter g: that referes to \\servername\d\foldername How do I get java to convert it from g: to the real path so I can use it? I have a script that...
2
by: lastusernameleft | last post by:
Is there a .NET method for doing this? I haven't found anything else that works. Thanks
1
by: Mark | last post by:
I posted this question some time ago, but didn't get a response. So, I'll try again. Hello, I have a VB.NET app which polls mapped drives periodically looking for files. However, if the...
2
by: Ian Murrell | last post by:
My application writes a text data file to a folder on another computer. The other computer is mapped by drive letter to the root (C) shared folder, eg as G:. The network is simple peer2peer, shared...
2
by: Ben | last post by:
Hi, Thanks for reading this post... I am trying to get the computer/server names from the mapped drives on the Clients PC when they select a file from the upload "browse" button. When the user...
4
by: Jim Carlock | last post by:
function CreateMyDataBaseFile($FQFN, $UID, $PW) { $db = "sqlite:" . $FQFN; $sql = "CREATE TABLE Customers(name1 TEXT, name2 TEXT);"; $dbh = new PDO($db, $UID, $PW); $dbh->exec($sql); $dbh =...
5
by: BigM | last post by:
Hi Guys, I am working up a little 'documents' section to an app of mine, where people can add links to docs on various share drives in our LAN, and they are displayed along with other details and...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
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...
0
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,...
0
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...

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.