Compare two directories

  • Thread starter Thread starter Peter Larsen []
  • Start date Start date
P

Peter Larsen []

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
 
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/default.asp?url=/library/en-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/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
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
 
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
 
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/advapi32/WNetGetUniversalName.html.
and here:
http://msdn.microsoft.com/library/d.../wnet/determining_the_location_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
 
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
 
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
 
Back
Top