[Mono-bugs] [Bug 77482][Nor] New - DirectoryInfo.GetFiles() failes with international characters

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon Feb 6 10:17:38 EST 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by stonebone at planetunreal.com.

http://bugzilla.ximian.com/show_bug.cgi?id=77482

--- shadow/77482	2006-02-06 10:17:38.000000000 -0500
+++ shadow/77482.tmp.3627	2006-02-06 10:17:38.000000000 -0500
@@ -0,0 +1,89 @@
+Bug#: 77482
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: System
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: stonebone at planetunreal.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: DirectoryInfo.GetFiles() failes with international characters
+
+I've written a simple program to illustrate the problem.
+
+using System;
+using System.IO;
+
+public class FileTest
+{
+	public static void Main (string [] args)
+	{
+		foreach(string dir in args)
+		{
+			Console.Write(dir);
+			DirectoryInfo dinfo = new DirectoryInfo (dir);
+			if(dinfo.Exists)
+			{
+				Console.WriteLine(" exists.");
+
+				foreach(FileInfo finfo in dinfo.GetFiles())
+				{
+					Console.WriteLine("\t" + finfo.Name);
+				}
+			}
+			else
+			{
+				Console.WriteLine(" does not exist.");
+			}
+		}
+	}
+}
+
+
+When I run this program it throws an exception if a filename contains
+international characters encoded with something other than utf-8. Example:
+
+kweek filetest% MONO_EXTERNAL_ENCODINGS="iso-8859-1" mono --debug
+FileTest.exe birch
+birch does not exist.
+kweek filetest% mkdir birch
+kweek filetest% MONO_EXTERNAL_ENCODINGS="iso-8859-1" mono --debug
+FileTest.exe birch
+birch exists.
+kweek filetest% MONO_EXTERNAL_ENCODINGS="iso-8859-1" mono --debug
+FileTest.exe björk
+björk does not exist.
+kweek filetest% mkdir björk
+kweek filetest% MONO_EXTERNAL_ENCODINGS="iso-8859-1" mono --debug
+FileTest.exe björk
+björk exists.
+
+Unhandled Exception: System.IO.FileNotFoundException: Could not find file
+"/home/stonebone/tmp/filetest/björk" : /home/stonebone/tmp/filetest/björk
+in [0x00166] (at
+/home/build/repos/extra/devel/mono/src/mono-1.1.13.2/mcs/class/corlib/System.IO/Directory.cs:445)
+System.IO.Directory:GetFileSystemEntries (System.String path, System.String
+pattern, FileAttributes mask, FileAttributes attrs)
+in [0x00005] (at
+/home/build/repos/extra/devel/mono/src/mono-1.1.13.2/mcs/class/corlib/System.IO/Directory.cs:250)
+System.IO.Directory:GetFiles (System.String path, System.String pattern)
+in [0x00007] (at
+/home/build/repos/extra/devel/mono/src/mono-1.1.13.2/mcs/class/corlib/System.IO/DirectoryInfo.cs:143)
+System.IO.DirectoryInfo:GetFiles (System.String pattern)
+in [0x00006] (at
+/home/build/repos/extra/devel/mono/src/mono-1.1.13.2/mcs/class/corlib/System.IO/DirectoryInfo.cs:137)
+System.IO.DirectoryInfo:GetFiles ()
+in (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo:GetFiles ()
+in [0x00037] (at /home/stonebone/tmp/filetest/FileTest.cs:18) FileTest:Main
+(System.String[] args)
+
+
+Notice that Exists returns true, yet GetFiles() it throws
+FileNotFoundException.


More information about the mono-bugs mailing list