473,320 Members | 1,945 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,320 software developers and data experts.

Compare two directories

Hi,

If i have a mapped drive and an UNC path - both pointing to the same
directory on the server, how do i determine if they match (point to the same
directory on the server) ??

Thank you.
BR
Peter
Aug 3 '06 #1
8 2385
The API call would be WNetGetConnection
http://msdn.microsoft.com/library/en...asp?frame=true

Not sure if there is a WMI equivalent.

Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung

"Peter Larsen []" <Pe*********@newsgroups.nospamwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Hi,

If i have a mapped drive and an UNC path - both pointing to the same
directory on the server, how do i determine if they match (point to the
same directory on the server) ??

Thank you.
BR
Peter

Aug 3 '06 #2
Hi Peter,

I agree with Greg that you should use the Windows Networking (WNet)
functions to do determin whether a mapped driver and a UNC path match.

But I think the WNetGetUniversalName function is a better candidate. You
could use this function to get the UNC path of a mapped driver and then
compare it with the previous UNC path.

For more information on how to use the WNetGetUniversalName function, you
could refer to the following link:

http://msdn.microsoft.com/library/de...us/wnet/wnet/d
etermining_the_location_of_a_share.asp

Hope this helps.
If you have anything unclear, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 4 '06 #3
Hi Linda and Greg,

Thank you for your comments.

I already have tried the WNetGetUniversalName function (and also the demo
from the link below), but it doesn't work as expected.

Take a look at the following sample:

I have a mapped drive: p:\myname.
Using WNetGetUniversalName it returns
\\companyname\country\location\temp\myname.
But this is a very long name, so normally i would just write
\\servername\temp\myname or p:\myname.

The problem is that i can't find a way to match
\\companyname\country\location\temp\myname with \\servername\temp\myname or
\\servername\temp\myname with p:\myname.

Parsing \\servername\temp\myname to WNetGetUniversalName fails.

Any ideas ?

Regards
Peter

"Linda Liu [MSFT]" <v-****@online.microsoft.comwrote in message
news:j3**************@TK2MSFTNGXA01.phx.gbl...
Hi Peter,

I agree with Greg that you should use the Windows Networking (WNet)
functions to do determin whether a mapped driver and a UNC path match.

But I think the WNetGetUniversalName function is a better candidate. You
could use this function to get the UNC path of a mapped driver and then
compare it with the previous UNC path.

For more information on how to use the WNetGetUniversalName function, you
could refer to the following link:

http://msdn.microsoft.com/library/de...us/wnet/wnet/d
etermining_the_location_of_a_share.asp

Hope this helps.
If you have anything unclear, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Aug 4 '06 #4
Hi Peter,

I performed a test on the demo from the msdn link in VC++ 6.0 and got the
correct result.

I mapped P: to a UNC "\\sha-bp-01\myfolder". I run the demo from the
command prompt and pass "P:\" as a parameter to this program.

I got the following result:

Call WNetGetUniversalName using UNIVERSAL_NAME_INFO_LEVEL.
Universal Name: \\sha-bp-01\myfolder\

Call WNetGetUniversalName using REMOTE_NAME_INFO_LEVEL.
Universal Name: \\sha-bp-01\myfolder\
Connection Name: \\sha-bp-01\myfolder
Remaining Path: \

Would you tell me in what IDE you are testing the demo? What drive do you
map to a UNC? What parameter do you pass to the program?

I look forward to your reply.
Sincerely,
Linda Liu
Microsoft Online Community Support
Aug 4 '06 #5
Hi Linda,

The mapped drive is bound to \\companyname\country\location etc, and i guess
that's the reason for why WNetGetUniversalName return that UNC path.
But no one use that path locally, since its too long to write. We simply use
the local servername \\servername\temp etc.

The code i'm using in my test, is found here;
http://www.pinvoke.net/default.aspx/...ersalName.html.
and here:
http://msdn.microsoft.com/library/de...of_a_share.asp

My environment is VS 2003 + 2005, C++/MFC and C#, dotNet 2,0, XP
professional, fully updated on a Windows server network.

BR
Peter
Aug 4 '06 #6
You are right Linda WNEtGetUniversalName is a better cantidate.

"Linda Liu [MSFT]" <v-****@online.microsoft.comwrote in message
news:j3**************@TK2MSFTNGXA01.phx.gbl...
Hi Peter,

I agree with Greg that you should use the Windows Networking (WNet)
functions to do determin whether a mapped driver and a UNC path match.

But I think the WNetGetUniversalName function is a better candidate. You
could use this function to get the UNC path of a mapped driver and then
compare it with the previous UNC path.

For more information on how to use the WNetGetUniversalName function, you
could refer to the following link:

http://msdn.microsoft.com/library/de...us/wnet/wnet/d
etermining_the_location_of_a_share.asp

Hope this helps.
If you have anything unclear, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Aug 4 '06 #7
Hi Peter,

I have mentioned that you have posted a same post in another thread, which
is being handled by Walter. You may check the answer that Walter has given
you there.

Thank you for your understanding.

Sincerely,
Linda Liu
Microsoft Online Community Support
Aug 7 '06 #8
Hi Linda,

The idea was to have you to look at this problem in a general way and Walter
from the Shell perspective.
But if you think we should leave it to Walter to find a solution, its ok
with me :-)

BR
Peter
Aug 9 '06 #9

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

Similar topics

6
by: Robin Siebler | last post by:
I have two directory trees that I want to compare and I'm trying to figure out what the best way of doing this would be. I am using walk to get a list of all of the files in each directory. I...
4
by: could ildg | last post by:
I want to compare 2 directories, and find If all of theire sub-folders and files and sub-files are identical.. If not the same, I want know which files or folders are not the same. I know filecmp...
0
by: Jeff Higgins | last post by:
Hi all Newbie to XPath. Can someone help with an XPath expression(s) that will accomplish the following using JAXP in J2SE-1.5. Thanks Jeff Higgins In a class I have two private org.w3c.dom...
1
by: Heath | last post by:
I'm dealing with a C# application that monitors changes to the file system, and need to exclude irrelevent directories, temp directories for example. Is there any way to identify such...
3
by: could.net | last post by:
I want to compare 2 directories: dir1 and dir2. What I want to do is to get these informations: 1. does they have the same number of files and sub-directories? 2. does each file with the same name...
4
by: rn5a | last post by:
I have a ListBox which should list all the files & directories that exist in a particular directory. The problem is I can get the ListBox to list either all the files or all the directories but not...
5
by: stamatis32 | last post by:
Hello everybody, i want to make a prog to compare the contents of 2 dirs. You can compare easily 2 files, but how this happend with dirs. I am very confused, i dont know where to start from, can...
1
by: Richard | last post by:
I'm writing code to compare two directories side-by-side, like FolderMatch or FolderSync. I've used ListBoxes in VB6, so have the idea about concatenating strings for list items, but have no...
6
by: =?Utf-8?B?WW9naSBXYXRjaGVy?= | last post by:
Hello, I am using Visual Studio-2003. I created a project to build my library. Since I am using third party libraries as well, I have specified those additional library dependencies in project...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.