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

  • Home
  • SEARCH
  • 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 3311824
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:55:20+00:00 2026-05-17T21:55:20+00:00

I have created a web application which is creating and updating the xml file

  • 0

I have created a web application which is creating and updating the xml file on daily basis. i.e. Creating a xml as currentdate.xml. This have all the records of user’s visited i.e IP, refferer, visited page and some more.

So the same file updating from multiple users at same time. So what are the best practice to check the file existence & updating.

I am getting the “File is in use by another process”

Thanks,
Laxmilal

  • 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-17T21:55:20+00:00Added an answer on May 17, 2026 at 9:55 pm

    You should not use file in a multi-threaded applications because the concurrency issues.

    An example can be this content of a file:

    Referrer: http://google.com
    RefReferrer: http://stackoverflow.com
    errer: http://meta.com
    Referrer: http://yahoo.com

    And this is pretty basic issue.

    Instead, you can use file-based database (such as SQLite) or, of course, a proper database (not necessarily RDBMS).

    Or in the worst case you have to synchronise the writes manually:

    static class Stats {
      static object locker = new object();
    
      public static Write(string someData) {
        lock(locker) {
            using (var stream = File.Open("pathtofile", FileMode.Append, FileAccess.Write, FileShare.ReadWrite))
            using (var writer = new StreamWriter(stream)) {
                writer.WriteLine(someData);
            }
        }
      }
    }
    

    NOTE here:

    • the synchronisation is handled within one and only one application (so you cannot generally have multiple processes working with the file;
    • you don’t need to check whether file exists or not. FileMode.Append will take care of that.

    Another option would be to use Log4net that does handle the concurrency much better.
    So that you can write your stats as log files:

    static class Stats {
      private static readonly ILog log = LogManager.GetLogger(typeof (Stats));
    
      public static Write(string someData) {
        log.Info(someData)
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a Web Application in asp.net 2.0. which is working fine on
We have created a web application, using ASP.NET, that allows users to upload documents
I have created a timeclock application in C# that connects to a web service
I have created an web service I need to publish this service. I need
I have created a web service which has a couple of methods developed using
Normally I create web application projects and use code-behind, but I have a requirement
I have created a PHP-script to update a web server that is live inside
I have created a Visual Studio 2008 sp1 test suite web test that uploads
I have a web service that I created in C# and a test harness
I have a web service I'm trying to load test. I created a program

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.