the Save method of XMLDocument or XElement

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
When I test the disk space not enough case, I got an unhandled Exception even Save method is in a try/catch. the code is something like below:

<div style="color:Black; background-color:White
<pre> <span style="color:Blue try
{
doc.Load(<span style="color:#A31515 @"XXXXXXXaaaaaaa_20100913.xml<span style="color:#A31515 ");[/code]

<div style="color:Black; background-color:White
<pre> .........
[/code]

<div style="color:Black; background-color:White
<pre> doc.Save(<span style="color:#A31515 @"XXXXXXXaaaaaaa_20100913.xml<span style="color:#000000 <span style="color:#A31515 "); //write back<br/> }
<span style="color:Blue catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
[/code]


after <span style="font-family:monospace; white-space:pre MessageBox.Show ,I got the below Exception

<span style="font-family:monospace <span style="white-space:pre システムエラーが発生しました。エラー詳細:ディスクに十分な空き領域がありません。 (the disk space is not enough)
<span style="font-family:monospace <span style="white-space:pre 場所 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 場所 System.IO.FileStream.WriteCore(Byte[] buffer, Int32 offset, Int32 count)

<span style="font-family:monospace <span style="white-space:pre 場所 System.IO.FileStream.FlushWrite(Boolean calledFromFinalizer) 場所 System.IO.FileStream.Dispose(Boolean disposing)

<span style="font-family:monospace <span style="white-space:pre 場所 System.IO.FileStream.Finalize()
<span style="font-family:monospace <span style="white-space:pre it seems that the Finalize was called by the framework and during Finalize, it try to write to disk again and throw the Exception. So how can I avoid this.
<span style="font-family:monospace <span style="white-space:pre or how can I catch the unhandled Exception.
And, if I want to add some node to an existing XML file, when the disk space is not enough I just want to hold the old file. but now the content of the old file even be deleted. so Is there any to do that?
<
Now that choose the destination, so we should keep on

View the full article
 
Back
Top