确定两条路径是否相同 [英] Determining if two paths are the same

查看:68
本文介绍了确定两条路径是否相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


给定两个相对或绝对格式的文件名,我需要确定它们是否指向同一个文件。虽然我可以简单地将每个传递给

" Path.GetFullPath()"并比较结果,关于

案例的规则是什么。也就是说,如何判断本地文件系统是否是区分大小写的
。我不想假设Windows是目标操作系统

,即使它实际上也是如此。谢谢。

Hi there,

Given two file names in relative or absolute format, I need to determine if
they point to the same file. While I can simply pass each to
"Path.GetFullPath()" and compare the results, what is the rule regarding
case. That is, how do you determine whether the local file system is
case-sensitive or not. I don''t want to assume that Windows is the target OS
even though realistically it will be. Thanks.

推荐答案

Windows文件系统不区分大小写。 Unix和其他一些是

区分大小写。


-

HTH,


Kevin Spencer

Microsoft MVP


打印组件,电子邮件组件,

FTP客户端类,增强型数据控件,多更多。

DSI PrintManager,Miradyne组件库:
http:/ /www.miradyne.net


" Mark Chambers" < no_spam@_nospam.com写信息

新闻:Om ************** @ TK2MSFTNGP04.phx.gbl ...
Windows File System is non-case-sensitive. Unix and some others are
case-sensitive.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Mark Chambers" <no_spam@_nospam.comwrote in message
news:Om**************@TK2MSFTNGP04.phx.gbl...

你好,


给定两个相对或绝对格式的文件名,我需要确定

如果他们指向同一个文件。虽然我可以简单地将每个传递给

" Path.GetFullPath()"并比较结果,关于

案例的规则是什么。也就是说,如何判断本地文件系统是否是区分大小写的
。我不想假设Windows是目标

操作系统,即使它实际上也是如此。谢谢。
Hi there,

Given two file names in relative or absolute format, I need to determine
if they point to the same file. While I can simply pass each to
"Path.GetFullPath()" and compare the results, what is the rule regarding
case. That is, how do you determine whether the local file system is
case-sensitive or not. I don''t want to assume that Windows is the target
OS even though realistically it will be. Thanks.



Windows文件系统不区分大小写。 Unix和其他一些是
Windows File System is non-case-sensitive. Unix and some others are

区分大小写。
case-sensitive.



谢谢。我正在尝试找到适当的.NET函数,告诉我

然而。

Thanks. I''m trying to find the appropriate .NET function that tells me that
however.


On Mon,2007年4月30日10:21 :06 -0700,Mark Chambers< no_spam@_nospam.com>

写道:
On Mon, 30 Apr 2007 10:21:06 -0700, Mark Chambers <no_spam@_nospam.com>
wrote:

> ; Windows文件系统不区分大小写。 Unix和其他一些是区分大小写的。
>Windows File System is non-case-sensitive. Unix and some others are
case-sensitive.



谢谢。我正在尝试找到适当的.NET函数,告诉我

然而。


Thanks. I''m trying to find the appropriate .NET function that tells me
that however.



我不知道(虽然这并不意味着它不存在)。如果存在一个

,在我看来它必须在某个组件中实际访问该文件。
实际访问该文件。喜欢获取所有文件

属性的东西,或打开文件或类似的东西。


那说,你应该记住,因为各种各样的方式

别名文件,即使根据简单的字符串路径不同

比较,无论你是否正确处理区分大小写,你,

仍可能有误报。你的目标听起来像是你只需要尝试,只要你不是100%重要,你总是得到

正确答案。

Pete

I don''t know of any (though that doesn''t mean it doesn''t exist). If one
exists, it seems to me that it would have to be in some component that
actually accesses the file. Like something that gets all of the file
properties, or opens the file, or something like that.

That said, you should probably keep in mind that because of various ways
to alias a file, even if the paths are different based on a simple string
comparison, whether you correctly deal with case-sensitivity or not, you
could still have false negatives. You goal sounds like something you
should only be trying if it''s not 100% important that you always get the
right answer.

Pete


这篇关于确定两条路径是否相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆