Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check Network Drive

Status
Not open for further replies.

robertfah

Programmer
Mar 20, 2006
380
US
Is there a way that I can check to see if a network drive is connected b4 I attempt to connect to it with a windows C# app?

I'm moving some files from one location to another and sometimes the network connection is lost overnight, so I don't want the program to bomb like it does now.

Thanks!
 
I don't know that you need to check if it is connected. You could simply use a try/catch block, with your file movement operations in the try portion. In the catch put a way to handle the 'drive not available' exception gracefully.

Hope this helps,

Alex

[small]----signature below----[/small]
Now you can go where the people are one!
Now you can go where they get things done!
 
Alex,

I know I can use the try/catch block but was curious if it did fail instead of throwing the 'drive not available' exception, I would somehow be able to just reconnect the drive.

I think there's a way to do it in a batch file if I remember correctly, but I guess I'm dating myself with that huh? LOL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top