PC Review


Reply
Thread Tools Rate Thread

How can I determine that two paths point to the same file?

 
 
Jeff Johnson
Guest
Posts: n/a
 
      22nd Mar 2010
Given two file paths, I would like to determine with certainty whether those
paths refer to the same physical file. Now, there is Path.GetFullPath(), and
that's very helpful. But what if I refer to a file on my machine through a
UNC path? Example:

C:\Temp\123.txt
\\MYCOMP\DRIVE_C\Temp\123.txt

\\MYCOMP\DRIVE_C is a share mapped to C:\, so ultimately both these paths
point to the same physical file. Does the .NET Framework provide any means
of mapping this? Please note that I don't in any way expect to get local
path translation for a REMOTE server, but I think it ought to be available
when a UNC path points to the LOCAL machine. If .NET offers nothing
built-in, does anyone know of a Windows API function that might do this?

I realize that I could enumerate shares and do all the heavy lifting myself;
I was just wondering if this sort of mapping is already written and
available to me.


 
Reply With Quote
 
 
 
 
Jani Järvinen [MVP]
Guest
Posts: n/a
 
      26th Mar 2010
Hello Jeff,

> Given two file paths, I would like to determine with certainty whether
> those paths refer to the same physical file.
> I was just wondering if this sort of mapping is already written and
> available to me.


I don't think a ready-made function exists for this, either in .NET or
Windows API. At least in .NET, you would need to enumerate the shares on the
(local) computer, and then check to which paths they point to. Note that on
NTFS, you can also mount disk partitions into directories, i.e. your regular
"E:\" could be mounted to "C:\MoreStuff".

So to make sure your code would work in all situations, your solution would
become quite complex, I'm afraid. However, in case of UNC paths and share on
the local computer, the solution ought to be quite straightforward.

Hope this helps!

--
Regards,

Jani Järvinen
C# MVP
Vantaa, Finland
E-mail: (E-Mail Removed)
Business: http://www.nimacon.net/
Personal: http://www.saunalahti.fi/janij/


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I determine if a point is a given distance from a secondpoint? Tom P. Microsoft C# .NET 8 1st Apr 2008 03:19 AM
determine if a point is an an ellipse illusion.admins@gmail.com Microsoft C# .NET 8 22nd Feb 2008 12:47 PM
How to determine a point on a sine wave MathNewbie Microsoft C# .NET 5 25th Oct 2006 09:28 PM
Determine Point Size of Text - Take 2 =?Utf-8?B?YmVu?= Microsoft Excel Programming 2 10th Feb 2006 02:59 AM
Power Point should use relative paths when referring to animation. =?Utf-8?B?Sm9oblU=?= Microsoft Powerpoint 1 6th Apr 2005 03:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:55 PM.