PC Review


Reply
Thread Tools Rate Thread

Directory.Getfiles issue

 
 
OpticTygre
Guest
Posts: n/a
 
      28th Oct 2004
I have a directory of 27 files. The files end in either 1.txt, 2.txt,
3.txt, or 4.txt.

If I say:

For Each filename As String In
Directory.GetFiles("C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\",
"*1.TXT")
Debug.WriteLine(filename)
Next

It prints out the following:

C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\E310920041.txt
C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\E311020041.txt
C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\HEI173680920044.txt
C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\HEI173680920042.txt
C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\HEI173680920043.txt
C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\HEI173680720041.txt
C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\HEI173680920041.txt
C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\R70136020720041.txt
C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\R70309010820041.txt
C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\R70332090920041.txt

Obviously, this is not correct. If my search string is "*2.TXT", "*3.TXT",
or "*4.TXT" it prints out alright. Has anyone seen this behavior before in
Directory.GetFiles?

-Jason


 
Reply With Quote
 
 
 
 
OpticTygre
Guest
Posts: n/a
 
      28th Oct 2004
The odd part is, if I change the code to:

Dim sFiles() As String =
Directory.GetFiles("C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\",
"*.txt")

For Each filename As String In sFiles
If filename.EndsWith("1.txt") Then Debug.WriteLine(filename)
Next

Then it prints out the correct information. Why would a search string of
*1.txt return things that don't end in 1.txt?


"OpticTygre" <(E-Mail Removed)> wrote in message
news:JYWdneG6U8PUsx3cRVn-(E-Mail Removed)...
>I have a directory of 27 files. The files end in either 1.txt, 2.txt,
>3.txt, or 4.txt.
>
> If I say:
>
> For Each filename As String In
> Directory.GetFiles("C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\",
> "*1.TXT")
> Debug.WriteLine(filename)
> Next
>
> It prints out the following:
>
> C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\E310920041.txt
> C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\E311020041.txt
> C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\HEI173680920044.txt
> C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\HEI173680920042.txt
> C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\HEI173680920043.txt
> C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\HEI173680720041.txt
> C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\HEI173680920041.txt
> C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\R70136020720041.txt
> C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\R70309010820041.txt
> C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\R70332090920041.txt
>
> Obviously, this is not correct. If my search string is "*2.TXT",
> "*3.TXT", or "*4.TXT" it prints out alright. Has anyone seen this
> behavior before in Directory.GetFiles?
>
> -Jason
>



 
Reply With Quote
 
Jay B. Harlow [MVP - Outlook]
Guest
Posts: n/a
 
      28th Oct 2004
Optic,
All of the "wrong" files have long file names, which suggests to me that
their short file name might be something ~1, which would match the *1.TXT".

You can use "dir /x" under the Command Prompt to see the 8.3 file names.

Unfortunately I don't know of any workarounds other then checking the names
returned from Directory.GetFiles. Note this is not to suggest there are not
other ways of limiting the search to long names...

Hope this helps
Jay


"OpticTygre" <(E-Mail Removed)> wrote in message
news:JYWdneG6U8PUsx3cRVn-(E-Mail Removed)...
>I have a directory of 27 files. The files end in either 1.txt, 2.txt,
>3.txt, or 4.txt.
>
> If I say:
>
> For Each filename As String In
> Directory.GetFiles("C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\",
> "*1.TXT")
> Debug.WriteLine(filename)
> Next
>
> It prints out the following:
>
> C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\E310920041.txt
> C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\E311020041.txt
> C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\HEI173680920044.txt
> C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\HEI173680920042.txt
> C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\HEI173680920043.txt
> C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\HEI173680720041.txt
> C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\HEI173680920041.txt
> C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\R70136020720041.txt
> C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\R70309010820041.txt
> C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\R70332090920041.txt
>
> Obviously, this is not correct. If my search string is "*2.TXT",
> "*3.TXT", or "*4.TXT" it prints out alright. Has anyone seen this
> behavior before in Directory.GetFiles?
>
> -Jason
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Directory.GetFiles() / DirectoryInfo.GetFiles() on a remote server =?Utf-8?B?RGFuaWVsIENvcnLDqmE=?= Microsoft ASP .NET 2 24th Mar 2007 06:59 PM
Directory.GetFiles File Order Issue =?Utf-8?B?U3RldmU=?= Microsoft Dot NET Framework 4 24th Aug 2005 06:46 PM
Bug in Directory.GetFiles? Bob L. Microsoft Dot NET Framework 5 14th Jul 2005 07:51 AM
.Net CF Directory.GetFiles bug JO Microsoft Dot NET Compact Framework 2 30th Jun 2004 09:24 PM
Directory.GetFiles help Michelle Microsoft C# .NET 0 9th Nov 2003 04:43 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:13 AM.