473,387 Members | 1,463 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,387 software developers and data experts.

Determining a Network Error from an IOException

We have a loop where we process a large number of files.

We need a way to make a distinction between the following two IOExceptions Messages:
1. The network path was not found.
2. The process cannot access the file "\\NetworkPath\FileName" because it is being used by another process.

In the first case we have a network connection problem and their is no need to continue the loop.
In the second case we simply need to skip that file and continue with the next.

Is their a way to make this distinction without resorting to examining the Message string?

TIA
Jul 21 '05 #1
2 1637
Jay:

AFAIK, you need to examine exception's info to make distinctions in general
within exceptions of the same type... However, you can check for
Directory.Exists to eliminate the first one...
if(Directory.Exists(@\\NetworkPath){
//try accessing the file.

}

If you do this check in the first place, then you can't throw a not found
exception so even though you're not technically drawing a programmatic
distinction, I think the end result is what you want.

HTH,

Bill
"Jay Pondy" <jpondy@NO_SPAMmindspring.com> wrote in message
news:37**********************************@microsof t.com...
We have a loop where we process a large number of files.

We need a way to make a distinction between the following two IOExceptions Messages: 1. The network path was not found.
2. The process cannot access the file "\\NetworkPath\FileName" because it is being used by another process.
In the first case we have a network connection problem and their is no need to continue the loop. In the second case we simply need to skip that file and continue with the next.
Is their a way to make this distinction without resorting to examining the Message string?
TIA

Jul 21 '05 #2
Jay:

AFAIK, you need to examine exception's info to make distinctions in general
within exceptions of the same type... However, you can check for
Directory.Exists to eliminate the first one...
if(Directory.Exists(@\\NetworkPath){
//try accessing the file.

}

If you do this check in the first place, then you can't throw a not found
exception so even though you're not technically drawing a programmatic
distinction, I think the end result is what you want.

HTH,

Bill
"Jay Pondy" <jpondy@NO_SPAMmindspring.com> wrote in message
news:37**********************************@microsof t.com...
We have a loop where we process a large number of files.

We need a way to make a distinction between the following two IOExceptions Messages: 1. The network path was not found.
2. The process cannot access the file "\\NetworkPath\FileName" because it is being used by another process.
In the first case we have a network connection problem and their is no need to continue the loop. In the second case we simply need to skip that file and continue with the next.
Is their a way to make this distinction without resorting to examining the Message string?
TIA

Jul 21 '05 #3

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

Similar topics

2
by: Jay Pondy | last post by:
We have a loop where we process a large number of files. We need a way to make a distinction between the following two IOExceptions Messages: 1. The network path was not found. 2. The process...
0
by: Jay Pondy | last post by:
We have a loop where we process a large number of files. We need a way to make a distinction between the following two IOExceptions Messages: 1. The network path was not found. 2. The process...
0
by: Nasir | last post by:
What do we need to do to make the connection to SQL Server 2005 via JNDI? Here is what is happening: Verifying JNDI binding Datasource properties: description=empty
1
by: Ryan Liu | last post by:
Hi, I have a 100 clients/ one server application, use ugly one thread pre client approach. And both side user sync I/O. I frequently see the error on server side(client side code is same, but...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...

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.