"In Use" exception on XMLDocument.Save - 02-20-2006 , 03:24 PM
When using XMLDocument.Save(strFileName) in .NET 2005, is there a way to
check (or trap) and see if the file is in use by another. I am using VB.NET.
Currently it just bombs and says the filename is in use by another. I want
to check or trap for this rather than blow-up. I tried using a Try...Catch,
but it bombs deep in the DOM, where I don't have control of it.
Here is the Code
Re: "In Use" exception on XMLDocument.Save - 02-21-2006 , 06:25 AM
exception then nevertheless try/catch around the Save call should allow
you to catch the exception.
You can also pass other arguments to Save than simply a string with a
file name, you can pass in a Stream for instance and if you create that
yourself as needed (e.g. a FileStream where the constructor allows you
all control of FileMode, FileAccess, FileShare settings) then your code
has more control.
Martin Honnen --- MVP XML
Re: "In Use" exception on XMLDocument.Save - 02-21-2006 , 11:12 AM
Actually, if a file is in use, you may not be able to get a FileStream
object off it. I think a try/catch will do in this case.
"Martin Honnen" <mahotrash (AT) yahoo (DOT) de> wrote
|Thread Tools||Search this Thread|