Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
08-18-2012, 07:11 PM #1
- Join Date
- Aug 2012
- Thanked 0 Times in 0 Posts
Problem with Writing to XML File in VB.NET
I have two VB.NET programs on different machines that need to read/write a shared XML file. The file is located in a shared folder on the network. First Program1 reads the XML file using XMLDocument and an IO stream. It processes it and then closes the stream. Program1 looks like this:
Dim doc As New Xml.XmlDocument Dim stream As New IO.StreamReader("\\192.168.1.2\Data\main.xml") doc.Load(stream) ' ...... gets some data from xml here stream.Close() stream.Dispose()
Dim doc As New Xml.XmlDocument '.... creates some data on XML document here doc.Save("\\192.168.1.2\Data\main.xml")
Can not access the file "\\192.168.1.2\Data\main.xml" because it is being used by another process.
It's confusing, because I close the file in Program1 and also Program2 writes to it after some seconds (I'm sure the Stream.Close() is executed).
First program is runned on a Windows 7 64-bit machine and the second on a Windows XP machine. I'm using Visual Studio 2005 with .NET Framework 2.
Please help! Thanks.
Last edited by amirahmadian; 08-19-2012 at 07:10 AM.