473,407 Members | 2,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

"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)

Feb 20 '06 #1
2 2210


Terry wrote:

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)


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/
Feb 21 '06 #2
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" <ma*******@yahoo.de> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...


Terry wrote:

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)


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/

Feb 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

40
by: Steve Juranich | last post by:
I know that this topic has the potential for blowing up in my face, but I can't help asking. I've been using Python since 1.5.1, so I'm not what you'd call a "n00b". I dutifully evangelize on the...
5
by: Paul Sullivan | last post by:
We are a state agency that views protected medical information via our intranet. The screens even have privacy shields. Alarmingly, uses can "Print" and "Save As" which destroys the protection of...
3
by: ek03 | last post by:
I have a web application that saves/loads XML documents. On occasion, an error is logged on the call to XmlDocument.Load: "process cannot access the file <filepath here> because it is being used by...
11
by: Tor Erik | last post by:
Hi, The reason is that my application does about 16 connects and data transfers per second, to the same 16 remote hosts. After approx 200 secs there are 4000 sockets waiting to be garbage...
25
by: samjnaa | last post by:
Please check for sanity and approve for posting at python-dev. In Visual Basic there is the keyword "with" which allows an object- name to be declared as governing the following statements. For...
1
by: craigslist.jg | last post by:
Hi, I've built a client side webpage for our internal users, which when loaded, generates some HTML within an iFrame. The HTML generated to the iFrame is then saved as HTML. I know it's useless...
1
by: =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?= | last post by:
I get the above error in some of the ASP.NET web applications on a server, and I need some help figuring out how to deal with it. This is a rather long post, and I hope I have enough details that...
4
by: fran7 | last post by:
Hi, from help in the javascript forum I found the error in some code but need help. This bit of code works perfectly, trouble is I am writing it to a javascript function so the height needs to be in...
5
Sl1ver
by: Sl1ver | last post by:
I have this piece of code public bool Write(string KeyName, object Value) { try { // Setting string subKey1 =...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.