Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New to the CF scene
    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("\\\Data\main.xml")
              ' ...... gets some data from xml here
    Program2 creates some nodes in XMLDocument and saves it to the same shared file. It looks like this:
               Dim doc As New Xml.XmlDocument
                '.... creates some data on XML document here
    And the problem: I run Program1 first and after some seconds, Program2. But when the second program attempts to write to the xml file I get an exception like this:
    Can not access the file "\\\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 08:10 AM.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts