Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7513335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:09:09+00:00 2026-05-30T00:09:09+00:00

when I write the XML file to hard drive using the following code XmlDocument

  • 0

when I write the XML file to hard drive using the following code

    XmlDocument doc = new XmlDocument();
    doc.Load("D:\\project\\data.xml");
    if (!Directory.Exists("D:\\project_elysian\\data\\" + System.DateTime.Today.ToString("dd-MM-yyyy")))
    {
        DirectoryInfo di = Directory.CreateDirectory("D:\\project_elysian\\data\\" + System.DateTime.Today.ToString("dd-MM-yyyy"));
    }
    XmlTextWriter writer = new XmlTextWriter("D:\\project_elysian\\data\\" + System.DateTime.Today.ToString("dd-MM-yyyy") + "\\" + System.DateTime.Now.ToString("HH-mm-ss") + ".xml", null);
    XmlTextWriter writerlatest = new XmlTextWriter("D:\\project\\data\\latest\\today.xml", null);
    writer.Formatting = Formatting.Indented;
    writerlatest.Formatting = Formatting.Indented;
    doc.Save(writer);
    doc.Save(writerlatest);
    doc = null;
    writer.Flush();
    writerlatest.Flush();

it writes the XML file as desired but after that when I try to read that XML file in the same asp.net page (code placed in a C# Code Behind file) using the following code, it gives an error

    string filename = "D:\\project\\data\\latest\\today.xml";

    XmlSerializer serializer = new XmlSerializer(typeof(searchResult));
    serializer.UnknownNode += new XmlNodeEventHandler(serializer_UnknownNode);
    serializer.UnknownAttribute += new XmlAttributeEventHandler(serializer_UnknownAttribute);
    FileStream fs = new FileStream(filename, FileMode.Open);

the error is as follows

The process cannot access the file 'D:\project\data\latest\today.xml' because it is being used by another process.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.IO.IOException: The process cannot access the file 'D:\project\data\latest\today.xml' because it is being used by another process.

EDIT: The file isn’t being used by any other process

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T00:09:12+00:00Added an answer on May 30, 2026 at 12:09 am

    Make sure you’re closing your writer with a call like writer.Close();

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a .xml file using the following code into the App_Data/posts.
I have to write an XML file using java.The contents should be written from
I need to write an error log to a XML file using Visual Basic
I want to write the bulk of data into xml file ,the data coming
Is it possible to modify/write data to an XML file without any server-side proxy(e.g.
I have the following XML file: <xml version=1.0 encoding=utf-8?> <Data> <Parameter1>1</Parameter1> </Data> I want
I know you can create an xml file with php $doc->save(write.xml) but is it
I want to write a XML file as below: <?xml version=1.0 encoding=UTF-8?> <books xmlns:xsd=http://www.w3.org/2001/XMLSchema
How to read the below xml file and write its content into a plain
I am trying to write a servlet that will send a XML file (xml

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.