Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old February 20th, 2006, 09:35 PM
Terry
Guest
 
Posts: n/a
Default "In Use" exception on XMLDocument.Save

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

Me.XMLDocument.Save(strFileName)

  #2  
Old February 21st, 2006, 12:35 PM
Martin Honnen
Guest
 
Posts: n/a
Default Re: "In Use" exception on XMLDocument.Save



Terry wrote:

[color=blue]
> 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
>
> Me.XMLDocument.Save(strFileName)[/color]

If the Save method calls some internal other methods that throw an
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
http://JavaScript.FAQTs.com/
  #3  
Old February 21st, 2006, 05:25 PM
Onawole, Clement Oladapo
Guest
 
Posts: n/a
Default Re: "In Use" exception on XMLDocument.Save

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@yahoo.de> wrote in message
news:%23XapeHuNGHA.3896@TK2MSFTNGP15.phx.gbl...[color=blue]
>
>
> Terry wrote:
>
>[color=green]
>> 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
>>
>> Me.XMLDocument.Save(strFileName)[/color]
>
> If the Save method calls some internal other methods that throw an
> 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
> http://JavaScript.FAQTs.com/[/color]


 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles