Click here to Skip to main content
15,887,442 members
Home / Discussions / C#
   

C#

 
QuestionCommunications cable connection between two computers Pin
KeithWT16-Aug-07 9:40
KeithWT16-Aug-07 9:40 
AnswerRe: Communications cable connection between two computers Pin
led mike16-Aug-07 9:57
led mike16-Aug-07 9:57 
GeneralRe: Communications cable connection between two computers Pin
KeithWT16-Aug-07 10:18
KeithWT16-Aug-07 10:18 
GeneralRe: Communications cable connection between two computers Pin
pbraun17-Aug-07 6:04
pbraun17-Aug-07 6:04 
QuestionOpen file error does not produce exception Pin
CTaylor8916-Aug-07 9:12
CTaylor8916-Aug-07 9:12 
AnswerRe: Open file error does not produce exception Pin
Justin Perez16-Aug-07 9:39
Justin Perez16-Aug-07 9:39 
GeneralRe: Open file error does not produce exception Pin
CTaylor8916-Aug-07 10:10
CTaylor8916-Aug-07 10:10 
GeneralRe: Open file error does not produce exception [modified] Pin
Justin Perez16-Aug-07 10:15
Justin Perez16-Aug-07 10:15 
No, I haven't tried this myself. Did you try using the code snippet I provided? Your are trying to catch a general Exception. No general exception is going to be produced if the file doesn't exist, you need to catch the FileNotFoundException.

I didn't actually read your code completely, but I thought I did. I tested the below code and it worked just fine.

System.IO.StreamReader sr =  null;<br />
try<br />
{<br />
  sr = System.IO.File.OpenText(@"C:\Data.txt");<br />
}<br />
catch (System.IO.FileNotFoundException)<br />
{<br />
  MessageBox.Show("Unable to locate upload file.");<br />
}<br />
catch (Exception ex)<br />
{<br />
  MessageBox.Show("general error.");<br />
}


-- modified at 16:28 Thursday 16th August, 2007

I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")

GeneralRe: Open file error does not produce exception Pin
CTaylor8916-Aug-07 10:36
CTaylor8916-Aug-07 10:36 
GeneralRe: Open file error does not produce exception Pin
Justin Perez23-Aug-07 2:10
Justin Perez23-Aug-07 2:10 
GeneralRe: Open file error does not produce exception Pin
CTaylor8927-Aug-07 6:14
CTaylor8927-Aug-07 6:14 
Question[C#] - Obtaining no: of files & file sizes Pin
aravinda77716-Aug-07 8:40
aravinda77716-Aug-07 8:40 
AnswerRe: [C#] - Obtaining no: of files & file sizes Pin
Luc Pattyn16-Aug-07 8:45
sitebuilderLuc Pattyn16-Aug-07 8:45 
Question[SOLVED] Castle ActiveRecord and abstract classes... Pin
Xiol3216-Aug-07 7:19
Xiol3216-Aug-07 7:19 
AnswerRe: Castle ActiveRecord and abstract classes... Pin
Not Active16-Aug-07 9:19
mentorNot Active16-Aug-07 9:19 
AnswerRe: Castle ActiveRecord and abstract classes... Pin
Mark Churchill16-Aug-07 15:46
Mark Churchill16-Aug-07 15:46 
GeneralRe: Castle ActiveRecord and abstract classes... Pin
Xiol3216-Aug-07 23:08
Xiol3216-Aug-07 23:08 
General[SOLVED] Re: Castle ActiveRecord and abstract classes... Pin
Xiol3216-Aug-07 23:58
Xiol3216-Aug-07 23:58 
QuestionDe-smellifying some code... Pin
martin_hughes16-Aug-07 6:56
martin_hughes16-Aug-07 6:56 
AnswerRe: De-smellifying some code... Pin
MidwestLimey16-Aug-07 7:24
professionalMidwestLimey16-Aug-07 7:24 
GeneralRe: De-smellifying some code... Pin
martin_hughes16-Aug-07 12:12
martin_hughes16-Aug-07 12:12 
GeneralRe: De-smellifying some code... Pin
Luc Pattyn16-Aug-07 13:03
sitebuilderLuc Pattyn16-Aug-07 13:03 
GeneralRe: De-smellifying some code... Pin
martin_hughes17-Aug-07 6:50
martin_hughes17-Aug-07 6:50 
GeneralRe: De-smellifying some code... Pin
MidwestLimey16-Aug-07 17:20
professionalMidwestLimey16-Aug-07 17:20 
AnswerRe: De-smellifying some code... Pin
PhilDanger16-Aug-07 8:15
PhilDanger16-Aug-07 8:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.