473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Question on Directory.GetFiles()

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
Dec 18 '07 #1
3 2525


"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.
>
Dec 19 '07 #2
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" <Fa************@discussions.microsoft.comwrote in
message news:2B**********************************@microsof t.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.
>>

Dec 19 '07 #3
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" <mi*************@suddenlink.netwrote in message
news:47**********************@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

Dec 19 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: CK | last post by:
I have the following code in a windows service, when I start the windows service process1 and process2 work fine ,When process 1) and 2) get completed process 3) starts and sofar so good. the...
6
by: CK | last post by:
I have the following code in a windows service, when I start the windows service process1 and process2 work fine , but final process (3) doesnt get called. i stop and restart the windows service...
3
by: S. Han | last post by:
I'm using Directory.GetFiles to enumerate files in a directory. The problem is if you have to enumerate all files + subdirectories recursively, it takes too much memory, and it fails. Is there...
2
by: Joe | last post by:
Hi, I have a following code which I use to display the files in a directory named Temp. If the Temp directory doesn’t have any files, then I want to display a message but I don’t know how to...
1
by: Starbuck | last post by:
Hi When the routine below is run it gets to the line - Dim fileEntries As String() = Directory.GetFiles(tString) and then freezes, there is no errors etc, the program just stops responding. The...
3
by: Nonee | last post by:
Ok ok... I have been staring at this for a generation or so now and it is not working. And it is something really simple too. I have a listbox of mp3s (flbMp3s). I have a textbox (txtSearch). I...
11
by: al jones | last post by:
I'm using filesystem.getfiles - and so far it's working correctly *however* I'd sure like to be able to pass it, as the last parameter, the extensions (plural) for which I'm looking. I assumed...
6
by: schaf | last post by:
Hi NG ! I have the following piece of code below. the first try/catch part would return true although I do not have permission to access this computer. The second try/catch part would return...
0
by: tshad | last post by:
I am trying to do multiple Directory.GetFiles and append the results to one array that I will process. I tried this: string strFiles; strFiles = Directory.GetFiles(SemaSettings.InputFilePath,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.