为什么dir * .txt也会返回* .txtf? [英] Why does dir *.txt return *.txtf also?
问题描述
毫无疑问,这已经被回答了:/我不确定如何说这个。 我只是希望文件one.txt返回我以为是dir * .txt
No doubt this has been answered already :/ I'm not certain how to word this. I just want the file one.txt to return by what I thought would be dir *.txt
这里有一些例子来显示它不像我曾经想过的那样。
Here are some examples to show that it doesn't behave like I had thought.
dir * .txt
dir *.txt
one.txt
one.txtf
dir * txt
dir *txt
one.txt
one.txtf
dir * txtf
dir *txtf
one.txtf
dir * tx?
one.txt
one.txtf
dir *。???
dir *.???
one.txt
one.txtf
dir one。
one.txt
dir *。???
dir *"."???
one.txt
one.txtf
推荐答案
EDITED
简而言之,DIR命令的工作原理就像您所暗示的那样,这是设计之一s。
EDITED
In short - by definition the DIR command works as you're implying so it's one of those "by design" things.
从Microsoft在 DIR 命令直接。这个解释比.NET框架下面有一个更大的一点。
From Microsoft on the DIR command directly. This explanation is a bit more winded than the below from the .NET framework.
从 MSDN .NET Framework实现
From MSDN on the .NET Framework Implementation
使用星号一个searchPattern中的通配符,例如 .txt,当扩展名只有三个字符长时,匹配行为不同于扩展名长度多于或者少于三个字符长。一个文件扩展名只有三个字符的searchPattern会返回扩展名为三个或更多字符的文件,其中前三个字符与searchPattern中指定的文件扩展名相匹配。一个文件扩展名为一个,两个或三个以上的字符的searchPattern只能返回只具有与searchPattern中指定的文件扩展名相匹配的扩展名的文件。当使用问号通配符时,此方法仅返回与指定文件扩展名匹配的文件。例如,在目录中给出两个文件file1.txt和file1.txtother两个文件,file?.txt的搜索模式只返回第一个文件,而file 的搜索模式.txt返回两个文件。
When using the asterisk wildcard character in a searchPattern, such as ".txt", the matching behavior when the extension is exactly three characters long is different than when the extension is more or less than three characters long. A searchPattern with a file extension of exactly three characters returns files having an extension of three or more characters, where the first three characters match the file extension specified in the searchPattern. A searchPattern with a file extension of one, two, or more than three characters returns only files having extensions of exactly that length that match the file extension specified in the searchPattern. When using the question mark wildcard character, this method returns only files that match the specified file extension. For example, given two files, "file1.txt" and "file1.txtother", in a directory, a search pattern of "file?.txt" returns just the first file, while a search pattern of "file.txt" returns both files.
这篇关于为什么dir * .txt也会返回* .txtf?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!