473,789 Members | 2,893 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"In Use" exception on XMLDocument.Sav e

When using XMLDocument.Sav e(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(strFileNam e)

Feb 20 '06 #1
2 2242


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(strFileNam e)


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*******@yaho o.de> wrote in message
news:%2******** ********@TK2MSF TNGP15.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(strFileNam e)


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
3047
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 goodness of Python whenever I talk with fellow developers, but I always hit a snag when it comes to discussing the finer points of the execution model (specifically, exceptions). Without fail, when I start talking with some of the "old-timers"...
5
1880
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 the health information at the level we want. QUESTION: Can we shut those off?? Any other suggestions?? Paul Sullivan
3
2477
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 another process." Why should a document read operation have any sort of locking issues - even if two users are attempting to read the file at the same time, this should not be a problem. I don't think this is happening at the same time as a...
11
6868
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 collected by the OS. At this point is seems that connect loops and starts using the same local addresses it used 4000 connections ago, resulting in an "Address already in use" exception. A possible solution to this would be to keep the connection to...
25
2593
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 example: with quitCommandButton .enabled = true .default = true end with
1
2462
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 to disable the Save As command, but can I at least intercept when they select this from the menu and display a message? Thanks
1
7114
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 someone who bothers to read all of it have some pointers. Note, I have posted the stack trace and the code exhibiting the problem further down so if you want to start by reading that, search for +++ Also note that I am unable to reproduce...
4
3897
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 &quot;&quot; instead of "" otherwise I get an error message. Can anyone suggest how to write it so that it writes &quot; instead of "". I have tried all combinations of adding &quot; to the code but as soon as I think I am there I get throw out again. if...
5
5083
Sl1ver
by: Sl1ver | last post by:
I have this piece of code public bool Write(string KeyName, object Value) { try { // Setting string subKey1 = "SOFTWARE\\QwixAssets"; RegistryKey rk = Registry.LocalMachine; RegistryKey sk1 = rk.CreateSubKey(subKey1);
0
9511
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10408
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7529
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5417
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4092
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3697
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.