Microsoft仍然不了解文件路径。 (strDrive& strDirectory&" \"& strFilename is INCORRECT) [英] Microsoft still does not understand file paths. (strDrive & strDirectory & "\" & strFilename is INCORRECT)

查看:71
本文介绍了Microsoft仍然不了解文件路径。 (strDrive& strDirectory&" \"& strFilename is INCORRECT)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为.NET框架很棒!


这很好,干净,合乎逻辑;与旧的微软相矛盾。



令我感到很遗憾的是,新的微软在文件方面仍然没有遵守自己的规则例如,许多Microsoft安装程序以及其他公司的安装程序都不起作用,因为它们以下列方式处理路径:




strPath = strDrive& strDirectory& " \" &安培; strFile =" C:" &安培; " \WrongDirectoryWithoutSlash" &安培; " \" &安培; " FILENAME.EXT" =" C:\WrongDirectoryWithoutSlash \Filename.ext"


这似乎是正确的......但事实并非如此。


什么如果目录是根目录会发生什么?


或者如果目录是正确的目录怎么办?


请看以下内容:



strPath = strDrive& strDirectory& " \" &安培; strFile =" C:" &安培; " \" &安培; " \" &安培; " FILENAME.EXT" =" C:\\Filename.ext"

strPath = strDrive& strDirectory& " \" &安培; strFile =" C:" &安培; " \CorrectDirectoryEndingWithASlash\" &安培; " \" &安培; " FILENAME.EXT" =" C:\CorrectDirectoryEndingWithASlash \\Filename.ext"


结果是一个带有双斜线的路径...因此错了......


一个不以斜杠结尾的目录定义为一个文件。


以斜杠结尾的文件按定义是一个目录。


名为bla的目录之间的区别以及名为bla的文件是斜线。


这就是程序如何知道差异。 (复制,目的地是文件还是目录?)

亲爱的微软,



如果你不明白像文件位置这么简单的东西...


(你知道......文件位置......最重要的是......一切都开始了。 ..)


....然后你必须成为什么?


你能解决这个非常老,漂亮的重要错误吗?


BTW-我喜欢你关于软件质量的写作( http://docs.msdnaa.net/ark_new3.0/cd...hapter%202.doc


你的,


BoonHead,失落的哲学家


我不是那个好好把它说成文字。


Actualy我很难把它说成文字。


但有没有人理解这个问题并且有没有人年龄或disa格力和我在一起?

I think the .NET framework is great!

It''s nice, clean and logical; in contradiction to the old Microsoft.



It only saddens me that the new Microsoft still doesn''t under stand there own rules when it comes to file paths.

A lot of Microsoft installers for example, and also installers of other companies, do not work because they handle paths in the following manner:



strPath = strDrive & strDirectory & "\" & strFile = "C:" & "\WrongDirectoryWithoutSlash" & "\" & "Filename.ext" = "C:\WrongDirectoryWithoutSlash\Filename.ext"

This seems correct...but it is not.

What happened if the directory is the root directory?

Or what if the directory is a correct directory?

Look at the following:



strPath = strDrive & strDirectory & "\" & strFile = "C:" & "\" & "\" & "Filename.ext" = "C:\\Filename.ext"
strPath = strDrive & strDirectory & "\" & strFile = "C:" & "\CorrectDirectoryEndingWithASlash\" & "\" & "Filename.ext" = "C:\CorrectDirectoryEndingWithASlash\\Filename.ext "

The result is a path with double slashes...and therefore wrong...

A directory not ending with a slash is by definition a file.

A file ending with a slash is by definition a directory.

The difference between the directory named "bla" and the file named "bla" is the slash.

That''s how programs know the difference. (Copy, "Is the destination a file or a directory?")
Dear Microsoft,



If you do not understand something as simple as file locations...

(You know..."file locations"...the most important thing...were it all begins...)

....then what must become of you?

Would you please fix this VERY OLD, PRETTY IMPORTANT BUG?

BTW- I loved your writing about software quality (http://docs.msdnaa.net/ark_new3.0/cd...hapter%202.doc)

Yours,

BoonHead, The Lost Philosopher

I''m not that good in putting it into words.

Actualy I''m pretty bad in putting this into words.

But does anyone understand this problem and does anyone agee or disagree with me?

推荐答案

嗨Boonhead。

你对斜线错了。文件和目录之间的区别

不是斜线。目录是设置了目录标志的文件。


这是文件系统知道的方式。它需要一个文件,检查目录

标志,并相应地对待它。


查看unix文件属性以确认这一点,你有标志

用于用户,组和其他人的读取,写入和执行权限,以及

目录标志。例如rw-r - r - d(请不要理解

的适用性这个许可设置btw:o))


您的问题是传递带有斜杠的目录名称。好吧,你好b $ b可以看到,你是在一个误用的情况下劳作,并创造你自己的

问题。


我可以建议吗,如果你需要将一个目录名称传递给一个字符串

格式化程序,它附加自己的尾部斜杠,你首先检查字符串

手动删除斜杠并删除它。不是一个棘手的代码:


如果正确(strDirectory,1)=" \"然后strDirectory = Left(strDirectory,

strDirectory.Length-1)


希望这会有所帮助,


Leon


" BoonHead,The Lost Philosopher" <博****** @ savagetiger.org>在留言中写道

新闻:3f *********************** @ news.euronet.nl ...

我认为.NET框架很棒!

这很好,干净而且合乎逻辑;与旧的微软相矛盾。


让我感到遗憾的是新的微软仍然没有站在那里

在文件方面有自己的规则例如,许多Microsoft安装程序以及其他

公司的安装程序都不起作用,因为它们以下列方式处理路径:


strPath = strDrive& strDirectory& " \" &安培; strFile =" C:" &

" \WrongDirectoryWithoutSlash" &安培; " \" &安培; " FILENAME.EXT" =

" C:\WrongDirectoryWithoutSlash \Filename.ext"


这似乎是正确的......但事实并非如此。

如果目录是根目录会发生什么?

或者如果目录是正确的目录怎么办?

请看以下内容:


strPath = strDrive& strDirectory& " \" &安培; strFile =" C:" &安培; " \" &安培; " \" &

" Filename.ext" =" C:\\Filename.ext"

strPath = strDrive& strDirectory& " \" &安培; strFile =" C:" &

" \CorrectDirectoryEndingWithASlash \" &安培; " \" &安培; " FILENAME.EXT" =

" C:\CorrectDirectoryEndingWithASlash \\Filename.ext"


结果是一个带有双斜线的路径...因此错误...

一个不以斜杠结尾的目录定义为一个文件。

以斜杠结尾的文件按定义是一个目录。

名为bla的目录之间的区别以及名为bla的文件是斜线。
斜线。

这就是程序如何知道差异。 (复制,目的地是文件

还是目录?)


亲爱的微软,


如果你不理解像文件位置这样简单的东西......

(你知道......文件位置......最重要的是......它是全部吗? />
开始...)

....然后你必须成为什么?

你能解决这个非常老,漂亮的重要错误吗?


BTW-我喜欢你关于软件质量的写作

http://docs.msdnaa.net/ark_new3.0/cd...co%5CMicrosoft

%20course%20-%20Chapter%202.doc)


你的,


BoonHead,失落的哲学家


我把它说成文字就不那么好了。

Actualy我把它说成文字很糟糕。

但有没有人理解这个问题,任何人都可以年龄或d isagree

和我在一起?
Hi Boonhead.
You''re wrong about the slash. The difference between a file and a directory
is not the slash. A directory is a file with the directory flag set.

This is how the file system knows. it takes a file, checks the directory
flag, and treats it accordingly.

Have a look at unix file attributes for confirmation of this, you have flags
for Read,Write and Execute permissions for Users,Groups and Others, and a
directory flag. eg rw-r--r--d (please don''t pull me up on the suitability of
this permission set btw :o) )

Your problem is passing a directory name with a trailing slash. Well as you
can see, you are labouring under a misapprension, and creating your own
problem.

Can I suggest, that if you need to pass a directory name to a string
formatter that appends its own trailing slash, that you check the string
first for a trailing slash manually and remove it. Not a tricky bit of code:

if Right( strDirectory, 1 ) = "\" Then strDirectory = Left(strDirectory,
strDirectory.Length-1 )

hope this helps,

Leon

"BoonHead, The Lost Philosopher" <bo******@savagetiger.org> wrote in message
news:3f***********************@news.euronet.nl...
I think the .NET framework is great!
It''s nice, clean and logical; in contradiction to the old Microsoft.

It only saddens me that the new Microsoft still doesn''t under stand there
own rules when it comes to file paths.
A lot of Microsoft installers for example, and also installers of other
companies, do not work because they handle paths in the following manner:

strPath = strDrive & strDirectory & "\" & strFile = "C:" &
"\WrongDirectoryWithoutSlash" & "\" & "Filename.ext" =
"C:\WrongDirectoryWithoutSlash\Filename.ext"

This seems correct...but it is not.
What happened if the directory is the root directory?
Or what if the directory is a correct directory?
Look at the following:

strPath = strDrive & strDirectory & "\" & strFile = "C:" & "\" & "\" &
"Filename.ext" = "C:\\Filename.ext"
strPath = strDrive & strDirectory & "\" & strFile = "C:" &
"\CorrectDirectoryEndingWithASlash\" & "\" & "Filename.ext" =
"C:\CorrectDirectoryEndingWithASlash\\Filename.ext "

The result is a path with double slashes...and therefore wrong...
A directory not ending with a slash is by definition a file.
A file ending with a slash is by definition a directory.
The difference between the directory named "bla" and the file named "bla" is
the slash.
That''s how programs know the difference. (Copy, "Is the destination a file
or a directory?")

Dear Microsoft,

If you do not understand something as simple as file locations...
(You know..."file locations"...the most important thing...were it all
begins...)
....then what must become of you?
Would you please fix this VERY OLD, PRETTY IMPORTANT BUG?

BTW- I loved your writing about software quality
(http://docs.msdnaa.net/ark_new3.0/cd...co%5CMicrosoft
%20course%20-%20Chapter%202.doc)

Yours,

BoonHead, The Lost Philosopher

I''m not that good in putting it into words.
Actualy I''m pretty bad in putting this into words.
But does anyone understand this problem and does anyone agee or disagree
with me?


亲爱的精益,


我通常会有这样的功能我的程序:


函数CorrectPath(strPath)作为字符串

''我希望它只是一个已作为
参数...有时你无法知道...

如果strPath.Length> 0然后

选择案例权利(strPath,1)

案例" \"," /"

返回strPath

Case Else

返回strPath& " /"

结束选择

结束如果

结束功能


但是那个'不是重点...


我知道FAT / DET是如何工作的但是我并没有提到

文件的物理部分和目录。

我指的是文字部分;路径。


如果这样做怎么办?:

C:\>复制" *。*" " NewName2"

如何读取不存在的对象的目录属性

(目录或文件)。

这只是一个蹩脚的例子......有更好的例子。


Unix好多了。 unix usualy有很好的正确的文本路径。

地狱,我甚至在文件浏览器中看到了每个目录名后面的斜线。

a Linux发行版一次:)(" bin / )


所以...

如果目录/文件不存在怎么办?如果路径没有物理

对象怎么办?

纯文本...没有斜线的目录是错误的并且会导致很多错误

如果程序员没有计算不合逻辑的话。 (我的意思是很多

的BUGS)

由优秀程序员编写的程序和程序库总是具有

标准尝试纠正不合逻辑的 - 代码,这是浪费字节和

时间。


你的,


BoonHead


" Leon Jollans" <乐********************** @ xaman.com>在消息中写道

新闻:#6 ************** @ TK2MSFTNGP10.phx.gbl ...
Dear Lean,

I usualy have something as this function in my programs:

Function CorrectPath(strPath) As String
''I hope it''s just a directory name that has been send as a
parameter...Sometimes you have no way of knowing...
If strPath.Length > 0 Then
Select Case Right(strPath, 1)
Case "\", "/"
Return strPath
Case Else
Return strPath & "/"
End Select
End If
End Function

But that''s not the point...

I know how the FAT/DET works but I wasn''t refering to the physical part of
files and directories.
I was refering to the textual part; paths.

What if do this?:
C:\>Copy "*.*" "NewName2"
How do you read the directory attribute of a non-existing "object"
(directory or file).
And this is just one lame example...there are better ones.

Unix is a lot better. Unix usualy has nice and correct textual paths.
Hell, I even saw slashes behind every directory name in the file browser in
a Linux distribution once :) ("bin/")

So...
What if the directory/file doesn''t exist? What if a path had no physical
object?
Pure textual...Directories without a slash are wrong and cause a lot of bugs
if the programmer doesn''t incalculate the illogicalness. (And I mean "A LOT
OF BUGS")
Programs and liberaries programmed by a good programmer always have the
standard "try-to-correct-illogicalness"-code which is a waste of bytes and
time.

Yours,

BoonHead

"Leon Jollans" <Le**********************@xaman.com> wrote in message
news:#6**************@TK2MSFTNGP10.phx.gbl...
嗨Boonhead。<你对斜线错了。文件和
目录之间的区别不是斜杠。目录是设置了目录标志的文件。

这是文件系统知道的方式。它需要一个文件,检查目录
标志,然后对其进行处理。

看看unix文件属性以确认这一点,你有读取,写入的
标志和用户,组和其他人的执行权限,以及
目录标志。例如rw-r - r - d(请不要理解这个权限集btw的适用性
:o))

你的问题是传递一个目录名带有斜线。好吧,你可以看到
,你在误用工作,并创建自己的
问题。

我可以建议,如果你需要将目录名传递给string
格式化程序附加自己的尾部斜杠,首先检查字符串
手动删除斜杠并删除它。
代码并不是一个棘手的问题:
如果正确(strDirectory,1)=" \"然后strDirectory = Left(strDirectory,
strDirectory.Length-1)

希望这会有所帮助,

Leon

BoonHead,失落的哲学家 <博****** @ savagetiger.org>写在
消息新闻:3f *********************** @ news.euronet.nl ...
我觉得。 NET框架很棒!
它很好,干净而且合乎逻辑;与旧的微软相矛盾。

让我感到很难过,新的微软仍然不会站在那里
自己的文件路径规则。
很多例如,Microsoft安装程序以及其他公司的安装程序不起作用,因为它们以下列方式处理路径:

strPath = strDrive& strDirectory& " \" &安培; strFile =" C:" &
" \ WrongDirectoryWithoutSlash" &安培; " \" &安培; " FILENAME.EXT" =
" C:\WrongDirectoryWithoutSlash \Filename.ext"

这似乎是正确的......但事实并非如此。
如果目录是根目录会发生什么?
或者如果目录是正确的目录怎么办?
请看以下内容:

strPath = strDrive& strDirectory& " \" &安培; strFile =" C:" &安培; " \" &安培; " \" &
" Filename.ext" =" C:\\Filename.ext"
strPath = strDrive& strDirectory& " \" &安培; strFile =" C:" &
" \CorrectDirectoryEndingWithASlash \" &安培; " \" &安培; " FILENAME.EXT" =
" C:\CorrectDirectoryEndingWithASlash \\Filename.ext"

结果是一个带有双斜线的路径...因此错了......
根据定义,不以斜杠结尾的目录是文件。
以斜杠结尾的文件根据定义是目录。
名为bla的目录之间的区别。以及名为bla的文件
是斜线。
这就是程序知道差异的方式。 (复制,目标是文件
还是目录?)

亲爱的微软,

如果您不理解文件这么简单的事情地点......
(你知道......文件位置......最重要的事情......一切都开始......)
...然后是什么必须成为你吗?
请你解决这个非常古老,重要的BUG?

顺便说一句 - 我喜欢你关于软件质量的写作

http://docs.msdnaa.net/ark_new3.0 /cd...co%5CMicrosoft %20course%20-%20Chapter%202.doc)

你的,

BoonHead,The Lost Philosopher
我把它用在文字中并不是那么好。
Actualy我很难用这句话说话。
但是有没有人理解这个问题而且是否有人年龄或者不同意
和我一起?
Hi Boonhead.
You''re wrong about the slash. The difference between a file and a directory is not the slash. A directory is a file with the directory flag set.

This is how the file system knows. it takes a file, checks the directory
flag, and treats it accordingly.

Have a look at unix file attributes for confirmation of this, you have flags for Read,Write and Execute permissions for Users,Groups and Others, and a
directory flag. eg rw-r--r--d (please don''t pull me up on the suitability of this permission set btw :o) )

Your problem is passing a directory name with a trailing slash. Well as you can see, you are labouring under a misapprension, and creating your own
problem.

Can I suggest, that if you need to pass a directory name to a string
formatter that appends its own trailing slash, that you check the string
first for a trailing slash manually and remove it. Not a tricky bit of code:
if Right( strDirectory, 1 ) = "\" Then strDirectory = Left(strDirectory,
strDirectory.Length-1 )

hope this helps,

Leon

"BoonHead, The Lost Philosopher" <bo******@savagetiger.org> wrote in message news:3f***********************@news.euronet.nl...
I think the .NET framework is great!
It''s nice, clean and logical; in contradiction to the old Microsoft.

It only saddens me that the new Microsoft still doesn''t under stand there
own rules when it comes to file paths.
A lot of Microsoft installers for example, and also installers of other
companies, do not work because they handle paths in the following manner:

strPath = strDrive & strDirectory & "\" & strFile = "C:" &
"\WrongDirectoryWithoutSlash" & "\" & "Filename.ext" =
"C:\WrongDirectoryWithoutSlash\Filename.ext"

This seems correct...but it is not.
What happened if the directory is the root directory?
Or what if the directory is a correct directory?
Look at the following:

strPath = strDrive & strDirectory & "\" & strFile = "C:" & "\" & "\" &
"Filename.ext" = "C:\\Filename.ext"
strPath = strDrive & strDirectory & "\" & strFile = "C:" &
"\CorrectDirectoryEndingWithASlash\" & "\" & "Filename.ext" =
"C:\CorrectDirectoryEndingWithASlash\\Filename.ext "

The result is a path with double slashes...and therefore wrong...
A directory not ending with a slash is by definition a file.
A file ending with a slash is by definition a directory.
The difference between the directory named "bla" and the file named "bla" is the slash.
That''s how programs know the difference. (Copy, "Is the destination a file
or a directory?")

Dear Microsoft,

If you do not understand something as simple as file locations...
(You know..."file locations"...the most important thing...were it all
begins...)
...then what must become of you?
Would you please fix this VERY OLD, PRETTY IMPORTANT BUG?

BTW- I loved your writing about software quality
(http://docs.msdnaa.net/ark_new3.0/cd...co%5CMicrosoft %20course%20-%20Chapter%202.doc)

Yours,

BoonHead, The Lost Philosopher

I''m not that good in putting it into words.
Actualy I''m pretty bad in putting this into words.
But does anyone understand this problem and does anyone agee or disagree
with me?



BoonHe广告,失落的哲学家< bo ****** @ savagetiger.org>写道:
BoonHead, The Lost Philosopher <bo******@savagetiger.org> wrote:
如果目录/文件不存在怎么办?如果路径没有物理对象怎么办?


然后它既不是常规文件也不是目录,是吗?是否应该将
创建为目录或文件是否符合

语义的相关应用程序。

纯文本..没有斜线的目录是错误的
What if the directory/file doesn''t exist? What if a path had no physical
object?
Then it''s neither a regular file nor a directory, is it? Whether it
should be created as a directory or a file is up to the semantics of
the application in question.
Pure textual...Directories without a slash are wrong




谨慎提供证明的任何文件。这个?这不是我曾经工作过的方式。我只是严格区分

的东西应该是什么文件以及什么时候应该是目录。


-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet

如果回复群组,请不要给我发邮件



Care to provide any documentation to "prove" this? It''s not the way
I''ve ever worked - I''ve just kept a strict distinction between when
things should be files and when they should be directories.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


这篇关于Microsoft仍然不了解文件路径。 (strDrive&amp; strDirectory&amp;&quot; \&quot;&amp; strFilename is INCORRECT)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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