Directory.GetFiles does not return files that have non-English names

As the subject implies, I'm trying to use Directory.GetFiles from within C# to grab all of the files in my directory. I have a few Chinese and Japanese files in there that GetFiles does not return. Is there some property that I need to set so that it will return these files? Any help would be much appreciated.

foreach (string d in Directory.GetDirectories("C:\\myfiles")) {
foreach (string f in Directory.GetFiles(d, "*.exe")) {
foundFiles.Add(f);
}
}

[495 byte] By [aur0ra] at [2007-12-24]
# 1

aur0ra wrote:

foreach (string d in Directory.GetDirectories("C:\\myfiles")) {
foreach (string f in Directory.GetFiles(d, "*.exe")) {
foundFiles.Add(f);
}
}

First your outer loop will get directories from only one level not internal levels E.g Directory -> Directory -> Directory.........

So You need only this:

foreach (string f in Directory.GetFiles("C:\\myfiles", "*.exe", SearchOption.AllDirectories)) //Third Paramater to automatically Traverse to inner Directories.

{

foundFiles.Add(f);

Console.WriteLine(f); // Debug this and see do you get each file I got it working on Chiense characters in file names
}

Best of Luck ;-)

RizwanSharp at 2007-8-31 > top of Msdn Tech,Visual C#,Visual C# General...
# 2
Ah, right on, thank you very much. I didn't even notice that it wasn't pulling files from that top directory and that just-so-happened to have all of my multi-lang files. That was killing me, I appreciate the help.
aur0ra at 2007-8-31 > top of Msdn Tech,Visual C#,Visual C# General...