Posted By: mawcc | Jul 1st @ 2:31 AM
page 1 of 1
Comments: 8 | Views: 894
Today I've been researching an error where an ASP.NET image handler would display a wrong screenshot. Interestingly it turned out that the Directory.GetFiles method as well as the DIR command list a wrong file in wildcard mode:



As can be seen, the first file shouldn't belong in this list. The directory contains close to 5000 files, and when I copy the 4 files from above into an emtpy directory the error doesn't appear.
Big Smile

It's the 8.3 file name; try dir /X then compare the results with your wildcard
No, you cannot make GetFiles return only long filenames but you can post filter them yourself. An

if (fileName.StartsWith("13440", StringComparison.OrdinalIgnoreCase))
{
...
}

will do the right thing. I wouldn't be too surprised if PowerShell does exactly the same thing.
We still need to deal with this kind of things... wow this is crazy.
I might be daft, but I don't see why this should be a problem for 8.3.

13434_13434 should surely be abbreviated to 13434_~1.xxx in 8.3?

Then it would not match the wildcard that mawcc has pointed out.

Not always. It really depends on how many files you have in that directory and how "similar" they are. Here's an example:

00CD04~7.TXT 00000000-10002787.txt
00C114~5.TXT 00000000-10002788.txt
00C514~3.TXT 00000000-10002789.txt
00C1F5~4.TXT 00000000-10002790.txt
00C5F5~4.TXT 00000000-10002791.txt

As you can see the short names are quite different and they'll match a dir wildcard like 00C*
Ah I see.

I was under the impression they abbreviated in a more predictable manner, but I can see why this is sometimes not the case.
page 1 of 1
Comments: 8 | Views: 894