DirectoryInfo.GetFiles已损坏 [英] DirectoryInfo.GetFiles is broken
问题描述
MSDN> 当扩展名完全是
三个字符长时,searchPattern的匹配行为与扩展名超过
三个字符长时不同。正好三个字符的searchPattern返回
文件,其扩展名为三个或更多字符。一个,两个或三个以上字符的一个,两个或三个以上字符的searchPattern只返回具有完全长度的扩展名
的文件。
什么< BLEEP>他们的想法是什么!
好吧,不是说我的系统没有...
由于可能的原因,MS决定了" * ABC"。应解释为
" * .abc *"?
-
Jonathan Allen
MSDN> "The matching behavior of searchPattern when the extension is exactly
three characters long is different from when the extension is more than
three characters long. A searchPattern of exactly three characters returns
files having an extension of three or more characters. A searchPattern of
one, two, or more than three characters returns only files having extensions
of exactly that length."
WHAT THE <BLEEP> WERE THEY THINKING!
Ok, not that I have that out of my system...
For what possible reason did MS decide that "*.abc" should be interpreted as
"*.abc*"?
--
Jonathan Allen
推荐答案
" Jonathan Allen" < x@x.x>在消息中写道
新闻:eT ************* @ TK2MSFTNGP12.phx.gbl ...
"Jonathan Allen" <x@x.x> wrote in message
news:eT*************@TK2MSFTNGP12.phx.gbl...
为什么可能的原因做了MS决定* .abc应该将
解释为*。abc *?
因为当你说*。abc时,它不知道你是指文件的长名称还是它的b / b
的简称。文件名1234567890.abcdef
的简称123456~1.abc符合你的模式。
-
真相,
James Curran
主页:< a rel =nofollowhref =http://www.noveltheory.comtarget =_ blank> www.noveltheory.com 工作: www.njtheater.com
博客: www.honestillusion.com 日间工作: www.partsearch.com
(注意新工作!)MSDN> 当扩展名为
时,searchPattern的匹配行为正好是三个字符长,这与扩展名长度超过三个字符时不同。正好三个字符的searchPattern返回扩展名为三个或更多字符的文件。一个,两个或三个以上字符的searchPattern只返回具有恰好该长度的
扩展名的文件。
什么< BLEEP>他们有什么想法!
好吧,不是说我的系统没有...
-
Jonathan Allen
For what possible reason did MS decide that "*.abc" should be interpreted as "*.abc*"?
Because when you say "*.abc", it doesn''t know if you are referring to
the file''s longname or it''s shortname. A file name "1234567890.abcdef" has
a short name of "123456~1.abc" which matches your pattern.
--
Truth,
James Curran
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
(note new day job!) MSDN> "The matching behavior of searchPattern when the extension is exactly three characters long is different from when the extension is more than
three characters long. A searchPattern of exactly three characters returns
files having an extension of three or more characters. A searchPattern of
one, two, or more than three characters returns only files having extensions of exactly that length."
WHAT THE <BLEEP> WERE THEY THINKING!
Ok, not that I have that out of my system...
--
Jonathan Allen
不确定您运行的是哪个OS .NET版本,但它在带有.NET v1.1 SP1的
XP SP2上按预期工作。
如果一个目录包含:
readme.abc
和
readme.abcde
GetfFiles(*。abc")
只返回readme.abc
Willy。
" Jonathan Allen" < x@x.x>在消息中写道
news:eT ************* @ TK2MSFTNGP12.phx.gbl ...
Not sure what OS .NET version you are running, but it works as expected on
XP SP2 with .NET v1.1 SP1.
so if a directory contains:
readme.abc
and
readme.abcde
GetfFiles(*.abc")
only returns readme.abc
Willy.
"Jonathan Allen" <x@x.x> wrote in message
news:eT*************@TK2MSFTNGP12.phx.gbl...
MSDN> 当扩展名为
时,searchPattern的匹配行为正好是三个字符长,这与扩展名长度超过三个字符时不同。正好三个字符的searchPattern返回扩展名为三个或更多字符的文件。一个,两个或多于三个字符的searchPattern只返回具有恰好长度的
扩展名的文件。
什么< BLEEP>他们有什么想法!
好吧,不是说我的系统已经出现了......
由于可能的原因,MS决定*。abc。应该被解读为
" * .abc *"?
-
Jonathan Allen
MSDN> "The matching behavior of searchPattern when the extension is
exactly
three characters long is different from when the extension is more than
three characters long. A searchPattern of exactly three characters returns
files having an extension of three or more characters. A searchPattern of
one, two, or more than three characters returns only files having
extensions
of exactly that length."
WHAT THE <BLEEP> WERE THEY THINKING!
Ok, not that I have that out of my system...
For what possible reason did MS decide that "*.abc" should be interpreted
as
"*.abc*"?
--
Jonathan Allen
我的带有.NET v1.1 w / o SP1的XP SP2就像文档所述的那样工作。
GetfFiles(" *。abc" )发现:
c:\readme.abc
c:\readme.abcde
只是什么<寻呼>他们在想什么? :^)
安装SP1后我会再试一次,看看会发生什么......
Greg
进口系统
进口System.IO
公共类测试
公共共享子主()
尝试
Dim di As DirectoryInfo = New DirectoryInfo(" c:\")
Console.WriteLine( 以.abc
结尾的{0}中的文件数是{1}",_
di,di.GetFiles(" *。abc" ).Length)
捕获e作为例外
Console.WriteLine(进程失败:{0},e.ToString())
结束尝试
Console.ReadLine()
结束子
结束班>
" Willy Denoyette [MVP]" <无线************* @ pandora.be>在消息中写道
新闻:%2 **************** @ TK2MSFTNGP12.phx.gbl ...
My XP SP2 with .NET v1.1 w/o SP1 works just as the documentation states.
GetfFiles("*.abc") finds:
c:\readme.abc
c:\readme.abcde
JUST WHAT THE <BLEEP> WERE THEY THINKING? :^)
I''ll try it again after installing SP1 and see what happens...
Greg
Imports System
Imports System.IO
Public Class Test
Public Shared Sub Main()
Try
Dim di As DirectoryInfo = New DirectoryInfo("c:\")
Console.WriteLine("The number of files in {0} ending with .abc
is {1}", _
di, di.GetFiles("*.abc").Length)
Catch e As Exception
Console.WriteLine("The process failed: {0}", e.ToString())
End Try
Console.ReadLine()
End Sub
End Class
"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
不确定您正在运行的OS .NET版本,但它在带有.NET v1.1 SP1的XP SP2上按预期工作。
因此,如果目录包含:
readme.abc
和
readme.abcde
GetfFiles(*。abc")
只返回readme.abc
Willy。
Jonathan Allen < x@x.x>在消息中写道
新闻:eT ************* @ TK2MSFTNGP12.phx.gbl ...
Not sure what OS .NET version you are running, but it works as expected on
XP SP2 with .NET v1.1 SP1.
so if a directory contains:
readme.abc
and
readme.abcde
GetfFiles(*.abc")
only returns readme.abc
Willy.
"Jonathan Allen" <x@x.x> wrote in message
news:eT*************@TK2MSFTNGP12.phx.gbl...
MSDN> 当扩展名为
时,searchPattern的匹配行为正好是三个字符长,这与扩展名长度超过三个字符时不同。正好三个字符的searchPattern
返回扩展名为三个或更多字符的文件。一个,两个或多于三个字符的searchPattern只返回具有恰好长度的
扩展名的文件。
什么< BLEEP>他们有什么想法!
好吧,不是说我的系统已经出现了......
由于可能的原因,MS决定*。abc。应该被解读为
" * .abc *"?
-
Jonathan Allen
MSDN> "The matching behavior of searchPattern when the extension is
exactly
three characters long is different from when the extension is more than
three characters long. A searchPattern of exactly three characters
returns
files having an extension of three or more characters. A searchPattern of
one, two, or more than three characters returns only files having
extensions
of exactly that length."
WHAT THE <BLEEP> WERE THEY THINKING!
Ok, not that I have that out of my system...
For what possible reason did MS decide that "*.abc" should be interpreted
as
"*.abc*"?
--
Jonathan Allen
这篇关于DirectoryInfo.GetFiles已损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!