> 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.

Signature
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
[quoted text clipped - 6 lines]
>
> Ok, not that I have that out of my system...
Greg Burns - 01 Oct 2004 15:09 GMT
Ah, now that at least sheds some light on the issue.
Now, why cannot Willy and I get the same results...
Greg
>> For what possible reason did MS decide that "*.abc" should be interpreted
> as
[quoted text clipped - 4 lines]
> has
> a short name of "123456~1.abc" which matches your pattern.
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.
> MSDN> "The matching behavior of searchPattern when the extension is
> exactly
[quoted text clipped - 12 lines]
> as
> "*.abc*"?
Greg Burns - 30 Sep 2004 23:58 GMT
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
> Not sure what OS .NET version you are running, but it works as expected on
> XP SP2 with .NET v1.1 SP1.
[quoted text clipped - 26 lines]
>> as
>> "*.abc*"?
Greg Burns - 01 Oct 2004 13:37 GMT
> I'll try it again after installing SP1 and see what happens...
FYI: SP1 behaves the same way. As would be expected.
Greg
> My XP SP2 with .NET v1.1 w/o SP1 works just as the documentation states.
>
[quoted text clipped - 60 lines]
>>> interpreted as
>>> "*.abc*"?
Willy Denoyette [MVP] - 01 Oct 2004 14:46 GMT
>> I'll try it again after installing SP1 and see what happens...
>
> FYI: SP1 behaves the same way. As would be expected.
>
> Greg
On XP SP2 and .NET v1.1 SP2
public static void Main()
{
string[] dirs = Directory.GetFiles(@"f:\", "*.abc");
Console.WriteLine("The number of files is {0}.", dirs.Length);
foreach (string dir in dirs)
{
Console.WriteLine(dir);
}
}
prints:
The number of files is 1.
f:\readme.abc
when f:\ contains redme.abc and readme.abcde
as expected.
Willy.
Greg Burns - 01 Oct 2004 15:06 GMT
>>> I'll try it again after installing SP1 and see what happens...
>>
[quoted text clipped - 22 lines]
>
> Willy.
Your code on my box shows both files! Only change I made was to put my test
files on C: drive.
The number of files is 2.
c:\readme.abc
c:\readme.abcde
Not sure what "is to be expected". Common sense says one thing. The
documentation says another. All my test have followed what the docs say.
Greg
using System;
using System.IO;
namespace ConsoleApplication2
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
public static void Main()
{
string[] dirs = Directory.GetFiles(@"c:\", "*.abc");
Console.WriteLine("The number of files is {0}.", dirs.Length);
foreach (string dir in dirs)
{
Console.WriteLine(dir);
}
Console.ReadLine();
}
}
}
Willy Denoyette [MVP] - 01 Oct 2004 16:21 GMT
> Your code on my box shows both files! Only change I made was to put my
> test files on C: drive.
[quoted text clipped - 7 lines]
>
> Greg
Directory.GetFiles calls Win32 API's FindFirstFile - FindNextFile , so IMO
"the expected behavior" is what these API return.
To be sure I wrote following C program, and the results are exactly the same
when run with f:\*.abc as argument.
#define _WIN32_WINNT 0x0400
#include <windows.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
WIN32_FIND_DATA FindFileData;
HANDLE hFind = FindFirstFile(argv[1], &FindFileData);
printf ("First file: %s\n", FindFileData.cFileName);
while (FindNextFile(hFind, &FindFileData))
{
printf ("Next file: %s\n", FindFileData.cFileName);
}
FindClose(hFind);
return (0);
}
Note that the FS is NTFS and I have NET v2.0 beta installed as well.
Willy.
Joep - 01 Oct 2004 15:09 GMT
On XP Pro, VS.NET Pro 7.1.3088, Net 1.1.4322 SP1 I get both. I will try SP2
and see what that gets me.