473,480 Members | 1,688 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

The file is being used by some other process

hi ,

Am trying to read from and write to a same xml file.i have no prob when
reading the xml file.but when i write to the same file i get the following
error even after closing the reader object(which is open).

The file is being used by some other process.

---------------------------------------------------

This is what am doing in the code:

i have used the XmlTextReader and loaded the file to an XmlDocument
object and closed the Reader object. and after the processing of the
documnet, am writing to the file by passing a XmltextWriter obj to the
save() method in XmlDocument class. [more over I came to know that the
reader.close() only changes the read state to closed]

-------------------------------------------------------

Code Block here:

xdoc.Load(fs); //Loading the file

try

{fs.Close(); //Closing the file

Thread.Sleep(1000);

}

catch

{Thread.Sleep(1000);}

xmltagfinder();

XmlNode unode;

nodelist=xdoc.GetElementsByTagName(xnode.Name);

unode=nodelist[0].FirstChild;
count=nodelist.Count;i=0;

while(i!=count)

{

if(unode.ParentNode.ParentNode.Name!="LIST_ITEMS")

{

if(Convert.ToInt32(unode.InnerText)==Convert.ToInt 32(id1))

{

unode.NextSibling.InnerText="";

unode.NextSibling.InnerText=name;

}

else

{

unode=nodelist[i].FirstChild;
}

}

i++;

xtr=null

xdoc.Save("d:/Dash2.xml"); //i also tried
xdoc.Save(fs);

}


regards
Jagadeesh
Nov 12 '05 #1
1 1897
Jagadeesh wrote:
Am trying to read from and write to a same xml file.i have no prob when
reading the xml file.but when i write to the same file i get the following
error even after closing the reader object(which is open).

The file is being used by some other process.
I cannot reproduce the problem. After calling to XmlReader.Close() the
doc can be saved into the same file.
try

{fs.Close(); //Closing the file

Thread.Sleep(1000);

} .... xdoc.Save(fs);


This is weird. fs has been closed already.

--
Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog
Nov 12 '05 #2

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

Similar topics

4
8288
by: Mountain Bikn' Guy | last post by:
I am having serious problems with the following IDE bug: Could not write to output file 'x.dll' -- 'The process cannot access the file because it is being used by another process. ' and BUG:...
6
5131
by: Ana | last post by:
Hi! I have problems with the following scenario: My application is developed using C# under .NET. It must run on all Windows versions starting from Windows 98. The user must open different...
1
6431
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
5
4700
by: bulldog8 | last post by:
I've read numerous posts and have tried multiple approaches that I found, but just cannot get a file renamed. I am using VB.Net 2002 ... Here is what I have tried: 1) Code common to all...
1
1328
by: rn5a | last post by:
How do I find out whether a file is currently being used by some process or not (including the ASP.NET process)? A Web Form has a ListBox which lists all the directories & files existing in a...
8
8840
by: =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= | last post by:
Hi; I copied a new set of files over to my ASP.NET dir (and subdirs) on our test server. This replaced every file for the app. When I first then tried to bring it up, I got the below error. ...
0
822
by: KUTTAN | last post by:
How can i determine whether a file is being used by a any process ? senario I am creating some pdf files on a server and mails it to some people as attachment. After it i have done the coding...
9
5391
by: tshad | last post by:
I am trying to get access to a file that may still being written because the file is so large (7-10MB). I get an error: The process cannot access the file 'c:\TestDocs\XMLFiles\492172.XML'...
1
47337
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
6904
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
7034
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
7076
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6732
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...
0
6886
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
4472
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2976
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1294
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 ...
1
558
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.