[Mono-bugs] [Bug 580090] New: GetFiles fails on search patterns containing directories

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Feb 16 03:49:39 EST 2010


http://bugzilla.novell.com/show_bug.cgi?id=580090

http://bugzilla.novell.com/show_bug.cgi?id=580090#c0


           Summary: GetFiles fails on search patterns containing
                    directories
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.4.x
          Platform: i686
        OS/Version: Ubuntu
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Mono.Addins
        AssignedTo: lluis at novell.com
        ReportedBy: christian.vecchiola at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


Created an attachment (id=342582)
 --> (http://bugzilla.novell.com/attachment.cgi?id=342582)
Source code and test data to reproduce the bug.

User-Agent:       Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.7)
Gecko/20100106 Ubuntu/9.10 (karmic) Firefox/3.5.7

The System.IO.Directory.GetFiles(string directory, string searchPattern) method
fails to execute when searchPattern contains an existing directory (ad es:
'directory/*'). 

On ubuntu systems (9.10) upon a call of the following type:

string items[] = Directory.GetFiles(".", "test/*");

the reported error is the following:

Unhandled Exception: System.IO.DirectoryNotFoundException: Could not find a
part of the path "./test"
  at System.IO.Directory.GetFileSystemEntries (System.String path,
System.String searchPattern, FileAttributes mask, FileAttributes attrs)
[0x00000] 
  at System.IO.Directory.GetFiles (System.String path, System.String
searchPattern) [0x00000] 
  at FilesAndDirs.Program.Main (System.String[] args) [0x00000] 

On Windows systems the same lines of code produces the expected output, which
is the list of file names in the test directory.

The specification provided by the MSDN documentation for the method, which is
available at: http://msdn.microsoft.com/en-us/library/wz42302f.aspx, explicitly
states that searchPattern should not contain invalid path chars, but the .NET
framework implementation tested on Windows XP systems (.NET 2.0) nicely handles
this input.





Reproducible: Always

Steps to Reproduce:
1. Untar the attachment and move to the bin/Debug directory.
2. Create a local directory named 'test' (mkdir test)
3. Save four files into the 'test' directory.
   ls -al > test/file1.txt
   ls -sl > test/file2.txt
   ls -as > test/file3.txt
   ls -als > test/file4.txt

3. Run the test application with the following arguments: . test/\*
   mono FilesAndDirs.exe . test/\*

Actual Results:  
Testing Directory.GetFiles(.,test/file1.txt)...
Unhandled Exception: System.IO.DirectoryNotFoundException: Could not find a
part of the path "./test"
  at System.IO.Directory.GetFileSystemEntries (System.String path,
System.String searchPattern, FileAttributes mask, FileAttributes attrs)
[0x00000] 
  at System.IO.Directory.GetFiles (System.String path, System.String
searchPattern) [0x00000] 
  at FilesAndDirs.Program.Main (System.String[] args) [0x00000] 

Expected Results:  
Testing Directory.GetFiles(.,test/*)...[OK - 4 Found]
Testing Directory.GetDirectories(.,test/*)...[OK - 0 Found]

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list