The file is being used by some other process

Discussion in 'ASP .Net Security' started by Jagadeesh, Jan 14, 2004.

  1. Jagadeesh

    Jagadeesh Guest

    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.ToInt32(id1))

    {

    unode.NextSibling.InnerText="";

    unode.NextSibling.InnerText=name;

    }

    else

    {

    unode=nodelist.FirstChild;


    }

    }

    i++;

    xtr=null

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



    }






    regards
    Jagadeesh
     
    Jagadeesh, Jan 14, 2004
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jagadeesh
    Replies:
    0
    Views:
    529
    Jagadeesh
    Jan 14, 2004
  2. Jagadeesh
    Replies:
    0
    Views:
    511
    Jagadeesh
    Jan 14, 2004
  3. Jagadeesh
    Replies:
    1
    Views:
    840
    William Ryan
    Jan 14, 2004
  4. Jagadeesh

    The file is being used by some other process

    Jagadeesh, Jan 14, 2004, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    137
    William Ryan
    Jan 14, 2004
  5. Jagadeesh

    The file is being used by some other process

    Jagadeesh, Jan 14, 2004, in forum: ASP .Net Security
    Replies:
    1
    Views:
    110
    Mark Berryman
    Jan 28, 2004
Loading...

Share This Page