Question on Directory.GetFiles()
Question on Directory.GetFiles()
am 18.12.2007 23:49:19 von Michael Jackson
In my .NET 2.0 VS 2005 VB application, I'm using Directory.GetFiles(path) to
get all the files in the directory. However, I'm getting an error regarding
"Illegal character in Path", even though I can copy, etc the file using the
Windows XP explorer.
I can trap the error, but then this traps the entire GetFiles() function,
not just the one bad file.
Is there a way to just trap for the one bad file and continue on?
Michael
RE: Question on Directory.GetFiles()
am 19.12.2007 02:24:00 von FamilyTreeMike
"Michael Jackson" wrote:
> In my .NET 2.0 VS 2005 VB application, I'm using Directory.GetFiles(path) to
> get all the files in the directory. However, I'm getting an error regarding
> "Illegal character in Path", even though I can copy, etc the file using the
> Windows XP explorer.
>
> I can trap the error, but then this traps the entire GetFiles() function,
> not just the one bad file.
>
> Is there a way to just trap for the one bad file and continue on?
>
> Michael
>
>
It is very likely the path you are sending it is wrong and has the bad
character.
>
Re: Question on Directory.GetFiles()
am 19.12.2007 17:39:03 von Michael Jackson
Yes, there is a bad character in one of the paths. Odd thing though, .NET
fails on it, but I can move, copy, etc through windows. I'm getting a list
of files from a copy of another hard drive. The file was created and saved
through Microsoft Word. How can Microsoft Word create a file name that .NET
cannot access through GetFiles().
When the GetFiles function encounters a file name with a bad character, the
function throws an exception, and the String Array being populated by the
GetFiles function is Nothing.
I just can't believe this is how Microsoft wrote this function. Why can it
not AT LEAST give me the files that do not have illegal characters in the
file name.
Thanks,
Michael
"Family Tree Mike" wrote in
message news:2BD60678-2DD6-46D4-9671-7E00C85E35D0@microsoft.com...
>
>
> "Michael Jackson" wrote:
>
>> In my .NET 2.0 VS 2005 VB application, I'm using Directory.GetFiles(path)
>> to
>> get all the files in the directory. However, I'm getting an error
>> regarding
>> "Illegal character in Path", even though I can copy, etc the file using
>> the
>> Windows XP explorer.
>>
>> I can trap the error, but then this traps the entire GetFiles() function,
>> not just the one bad file.
>>
>> Is there a way to just trap for the one bad file and continue on?
>>
>> Michael
>>
>>
>
> It is very likely the path you are sending it is wrong and has the bad
> character.
>
>>
Re: Question on Directory.GetFiles()
am 19.12.2007 17:42:42 von Michael Jackson
I'm sorry. I re-read the reply to my question and I see what you are saying
about passing in a path with an illegal character in it.
No, that is not the case, because I'm also getting the directories of that
directory via GetDirectories, and I do that BEFORE the GetFiles function.
When stepping thru the code in debug, I can see that I'm getting an array of
Directores.
Thanks
Michael
"Michael Jackson" wrote in message
news:47684e76$0$5280$bbae4d71@news.suddenlink.net...
> In my .NET 2.0 VS 2005 VB application, I'm using Directory.GetFiles(path)
> to get all the files in the directory. However, I'm getting an error
> regarding "Illegal character in Path", even though I can copy, etc the
> file using the Windows XP explorer.
>
> I can trap the error, but then this traps the entire GetFiles() function,
> not just the one bad file.
>
> Is there a way to just trap for the one bad file and continue on?
>
> Michael
>