![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | BUG? DirectoryInfo.GetFiles() wildcards fail on filenames > 8 characters When file names have more than eight characters, directory wildcards seems to stop working. I created two files shown in the directory listing below. In my C# program I was hoping to distinguish one from from another using DirectoryInfo.GetFiles("abc??????????????") to only return the first file. As it turns out, when file names are longer than eight characters the wildcards stop working. In the script below, I do a DIR, a DIR abc???? and a DIR abc?????. Note how both filenames show-up in the last query even though both of them have more than five characters following "abc". I can't be the first one to notice this. Is there another DirectoryInfo class substitute I should be using? C:\Users\Thomas\testdir>dir Volume in drive C is WINDOWS Volume Serial Number is 4CD9-E01A Directory of C:\Users\Thomas\testdir 05/19/2009 12:24 PM <DIR> . 05/19/2009 12:24 PM <DIR> .. 05/19/2009 12:22 PM 15 abc20090519123456 05/19/2009 12:23 PM 27 abcde20090519123456 2 File(s) 42 bytes 2 Dir(s) 46,888,103,936 bytes free C:\Users\Thomas\testdir>dir abc???? Volume in drive C is WINDOWS Volume Serial Number is 4CD9-E01A Directory of C:\Users\Thomas\testdir File Not Found C:\Users\Thomas\testdir>dir abc????? Volume in drive C is WINDOWS Volume Serial Number is 4CD9-E01A Directory of C:\Users\Thomas\testdir 05/19/2009 12:22 PM 15 abc20090519123456 05/19/2009 12:23 PM 27 abcde20090519123456 2 File(s) 42 bytes 0 Dir(s) 46,888,103,936 bytes free |
My System Specs![]() |
| | #2 (permalink) |
| | Re: BUG? DirectoryInfo.GetFiles() wildcards fail on filenames >8 characters I just discovered it's an 8.3 problem going back to the DOS days. What a horrible piece of luggage for MS to be carrying around that it's still not fixed. |
My System Specs![]() |
| | #3 (permalink) |
| | Re: BUG? DirectoryInfo.GetFiles() wildcards fail on filenames > 8 Hi Thomas, I'm afraid .Net uses the win32 way when dealing with file names and every now and then you may stumble upon shortcomings like not being able to open ntfs file names ending with several white space characters. Although perfectly legal on ntfs, win32 does not support it. It looks like win32 does its search on the 8.3 version of the filename if the search pattern is less or equal to 8.3, or possibly combine two searches. This would mean that it won't get any better even if you use the win32 methods like FindFirstFile directly. There are talks about changing how .net deals with the file system, but to my knowledge there are no changes yet (as of .Net 4). I fear in your case the only option is to change the search pattern such that it does not match the 8.3 name of the files. -- Happy Coding! Morten Wennevik [C# MVP] "Thomas Gagne" wrote: Quote: > I just discovered it's an 8.3 problem going back to the DOS days. > > What a horrible piece of luggage for MS to be carrying around that it's > still not fixed. > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: BUG? DirectoryInfo.GetFiles() wildcards fail on filenames >8 After realizing that I decided Regex's methods would do the trick. Only a few extra lines of code. |
My System Specs![]() |
| | #5 (permalink) |
| | Re: BUG? DirectoryInfo.GetFiles() wildcards fail on filenames > 8 On May 24, 10:25*pm, Thomas Gagne <TandGandGA...@xxxxxx> wrote: Quote: > After realizing that I decided Regex's methods would do the trick. *Only > a few extra lines of code. Thank you. =) |
My System Specs![]() |
| | #6 (permalink) |
| | Re: BUG? DirectoryInfo.GetFiles() wildcards fail on filenames > 8 On Jul 15, 11:53*am, Robin <theinht...@xxxxxx> wrote: Quote: > On May 24, 10:25*pm, Thomas Gagne <TandGandGA...@xxxxxx> wrote: > Quote: > > After realizing that I decided Regex's methods would do the trick. *Only > > a few extra lines of code. > Could you please show us how to implement the code? > > Thank you. =) I got it now. we have to filter by using Regex.IsMatch() function.thank you. |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Replace special characters in filenames - how? | PowerShell | |||
| Search port wildcards | General Discussion | |||
| filenames with [ characters | PowerShell | |||
| Wildcards starting with ~ | PowerShell | |||