Workaround: D:.

Adding the explicit current directory causes the returned strings to
be valid paths.

Do you want to add the bug to Connect?

-- 
Regards,
Mark Hurd, B.Sc.(Ma.)(Hons.)

(BTW Typos fixed below.)

On Sat, Mar 6, 2010 at 1:35 AM, Mark Hurd <[email protected]> wrote:
> On Sat, Mar 6, 2010 at 12:21 AM, Richard Carde <[email protected]> wrote:
> <snip>
>>
>> If I specify the path (first argument) as a drive letter (of a mapped drive)
>> only, and that drive has a current working directory other than the root, it
>> fails because GetFiles() returns an absolute path which is incorrect - it
>> prepends the filenames with a \.
>>
>> eg:
>>
>> H:\>CD Z:\data_to_process
>>
>> H:\>GetFilesTest.exe Z:
>>
>> Processing file Z:\file1.txt
>>
>> Processing file Z:\file2.txt
>>
>> ...
>>
>> This isn't correct. While it correctly enumerates the files within the
>> folder structure as specified, the path should be Z:file1.txt, etc.  Surely?
>
> I agree (and can confirm with DotLisp and .NET 2.0) and I think you've
> found a bug.
>
> Note that files in the "current" folder don't have the \ inserted.
> That is your example above is wrong, at least for me:
>
> T:windows-gcl-saved_acl2.zip.txt
> T:\lu\README.TXT
>
> The above is a sample of the output from
> (Directory:GetFiles "T:" "*.txt" System.IO.SearchOption:AllDirectories)
>
>> Tried with VS2008 & .Net 3.5 as well as VS2010 RC & .Net 4 - same behaviour.
>
> I think I can see the problem using Reflector in
> Directory.InternalGetFileDirectoryNames:
>
> Where it says:
>
>  If (data.userPath.Length > 0) Then
>  ch = data.userPath.Chars((data.userPath.Length - 1))
>  flag2 = ((ch = Path.DirectorySeparatorChar) OrElse (ch =
> Path.AltDirectorySeparatorChar))
>  End If
>
> I believe it should be
>  flag2 = ((ch = Path.DirectorySeparatorChar) OrElse (ch =
> Path.AltDirectorySeparatorChar) OrElse (ch =
> Path.VolumeSeparatorChar))
>
> But InternalGetFileDirectoryNames is quite complex...
>
> <snip>
>> --
>> Richard Carde
>>
> --
> Regards,
> Mark Hurd, B.Sc.(Ma.)(Hons.)
>

Reply via email to