IOException!!!!!!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

can anyone tell me why i sometimes get an IOExcaption with the following code

line1: fs = new FileStream(file, FileMode.Append, FileAccess.Write);
line2: stream = new StreamWriter(fs);

the problem happens with the above and also with stream =
File.AppendText(file)

can anyone help?
 
all it gives me is an IOException.....i have tried catching the derived
exceptions from the IOException class, like DirectoryNotFoundException and
FileNotFoundException, etc...but it skips them and only catches the base
IOException.
 
Thaynann said:
all it gives me is an IOException.....i have tried catching the derived
exceptions from the IOException class, like DirectoryNotFoundException and
FileNotFoundException, etc...but it skips them and only catches the base
IOException.

But what is the *message* of the exception?
 
i have this to catch the exception

catch(Exception e){ return e.Message;}

and all it returns is "IOException"..thats all e.Message contains.
 
Thaynann said:
i have this to catch the exception

catch(Exception e){ return e.Message;}

and all it returns is "IOException"..thats all e.Message contains.

I suggest you print out the whole exception - stack trace and
everything. That may help.
 
Thaynann said:
how do i print out the stack trace...im using the Compact Framework, is it
possible

Well, instead of returning e.Message, return e.ToString().
Alternatively, catch it in the debugger and examine the stack trace
there.
 
Back
Top