Posted By: Red5 | Oct 25th, 2007 @ 8:53 AM
page 1 of 1
Comments: 14 | Views: 4865
Red5
Red5
Systems Manager Curmudgen
Can someone explain to me why the first result in my result set is being returned?


?System.io.Directory.GetFiles(strFolder, "*0?0*.vb")

{Length=4}

(0): "C:\Inetpub\wwwroot\TestPath\PF\Reports\ReportWeekendingPayroll.aspx.vb"

(1): "C:\Inetpub\wwwroot\TestPath\PF\Reports\ReportSSItemResolutionMI0703.aspx.vb"

(2): "C:\Inetpub\wwwroot\TestPath\PF\Reports\ReportSSItemResolutionMI0704.aspx.designer.vb"

(3): "C:\Inetpub\wwwroot\TestPath\PF\Reports\ReportSSItemResolutionMI0704.aspx.vb"



Also, if I use a filter of *050*.vb, I still get a result back for the first item.
Changing the 5 to anything else and I don't get that first item back.

PeterF
PeterF
Early Adopter
*0?0* ..... sounds like you can better use a regular expression to check if individual results from *.* matches the mask...

Peter
Your code works fine on my PC. I get three results, not four.
Red5 wrote:

JChung2006 wrote:Your code works fine on my PC. I get three results, not four.


Did you create dummy files to match mine to get your results?

Yes.  What culture and UI culture are you running in?
stevo_
stevo_
Human after all
You sure your debug readout isn't reading something out first before your results? Perplexed
Hi Red5,

I have the same feature here on Windows Vista 64-bit (compiling C# .Net 2.0 in VS2008).

When searching for "*32*", the returned files also have filenames that do not have "32" in them. Really stange...

The code used:
string[] aFiles = Directory.GetFiles("D:\\Test", "*32*", SearchOption.AllDirectories);

Greetings,
Mark
This is even reproducable in XP SP3 and Server 2003 !

If you have AVG virusscanner installed, try this in C# code:

XP: string[] aFiles = Directory.GetFiles("C:\\Program Files\AVG", "*3*", SearchOption.AllDirectories);
Vista64: string[] aFiles = Directory.GetFiles("C:\\Program Files (x86)\\AVG", "*3*", SearchOption.AllDirectories);

Even in Cmd "dos"-box: "dir *3* /s /b"

And see what is returned:
C:\Program Files (x86)\AVG\AVG8\avgxch32.dll
C:\Program Files (x86)\AVG\AVG8\Icons\background_middle_yellow.gif
C:\Program Files (x86)\AVG\AVG8\Icons\background_middle_orange.gif
C:\Program Files (x86)\AVG\AVG8\Icons\background_top_yellow.gif
C:\Program Files (x86)\AVG\AVG8\Icons\border_bottom_orange.gif
C:\Program Files (x86)\AVG\AVG8\Icons\click_here_yellow.gif
C:\Program Files (x86)\AVG\AVG8\Icons\click_here_orange.gif
C:\Program Files (x86)\AVG\AVG8\Icons\icons_close.gif
C:\Program Files (x86)\AVG\AVG8\Icons\icons_safe.gif

Anybody knows why this happens?

I'm using in both XP and Vista64 the Dutch version of Windows.
The Server 2003 is english.

Thanks,
Mark
CannotResolveSymbol
CannotResolveSymbol
{insert caption here}
Could you post the output of dir /x in that directory?

I'll bet that all of those files have short names like SOMETH~3.EXT, in which case, it's not a bug, it's a "feature" (Windows maintains 8.3 names for all files for backwards compatibility, and all files can either be referenced by their long or short names).

If this is a problem, you have two options:  turn off short filename creation (which will cause problems with DOS and 16-bit Windows apps) or use a regular expression to filter results returned from Directory.GetFiles.
Yep, your right Smiley

Just turned 8.3 filenames off ("fsutil.exe behavior set disable8dot3 1") and only old files will be shown that have short names with the search filter.
New files will not have that strange feature anymore.

Any suggestions on how to convert a search filter to a regular expression?

Thanks,
Mark
page 1 of 1
Comments: 14 | Views: 4865
Microsoft Communities