Click to See Complete Forum and Search --> : C# - APP: Exception: The operation was canceled.


strakamichal
July 31st, 2008, 03:41 AM
Hi all,
i need help with one exception. I know only .Message of this exception and i know which part of code throws it.


Message:
.Message: "The operation was canceled."




Code:
try
{
FileIOPermission perm = new FileIOPermission(FileIOPermissionAccess.Write, file_name);
perm.Assert();
if (!additive && File.Exists(file_name)) File.Delete(file_name);
using(FileStream fs = new FileStream(file_name, FileMode.OpenOrCreate, FileAccess.ReadWrite))
{
using(StreamWriter writer = new StreamWriter(fs))
{
writer.BaseStream.Seek(0, SeekOrigin.End);
writer.Write(content);
writer.Flush();
writer.Close();

result = true;
}
fs.Close();
}
CodeAccessPermission.RevertAssert();
}
catch (System.Exception err)
{
System.Diagnostics.Debug.WriteLine(err.Message);
throw(err);
}
FYI: This Windows application runs for many years, but once this error was occured and stored in log. Can somebody help me? Is anythere List of exception messages, where I can find what does the exception mean?

eclipsed4utoo
July 31st, 2008, 08:26 AM
change this line:


System.Diagnostics.Debug.WriteLine(err.Message);


to


System.Diagnostics.Debug.WriteLine(err.ToString());


you will also get the stack trace when writing the entire error.

cjard
July 31st, 2008, 12:04 PM
This Windows application runs for many years, but once this error was occured and stored in log.

It ran for years and you care that this error happened once? Wow.. Not much to do at your work eh? :)