TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Phil Saville
NA
13
0
Ignore Exceptions
Sep 10 2009 4:50 AM
I am currently creating an application which searches through a directory and all its subdirectories for a certain file type and then if found displays this file type in a listbox.
heres my problem however, there are certain directories/subdirectories which i do not have access to so when i run my application i get an UnauthorizedAccessException and so the application fails to complete the search, i was wondering if there was a way i could ignore this exception and just continue the search with the next directory.
I would be very grateful for any help as i have been stuck for a while with no help, and i would appreciate some useful sample code if possible...here is the code i have at the moment....
private
void
button1_Click(
object
sender,
EventArgs
e)
{
try
{
listBox1.Items.Clear();
string
[] temp =
Directory
.GetFiles(
@"C:\"
,
"*.drl"
,
SearchOption
.AllDirectories);
for
(
int
i = 0; i < temp.Length; i++)
{
listBox1.Items.Add(temp[i]);
}
}
catch
(
UnauthorizedAccessException
)
{
throw
;
}
}
Reply
Answers (
1
)
Resource File usage
reading xml schema from c# and retriving all data from it