473,403 Members | 2,293 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,403 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 1639
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.