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 65709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:59:20+00:00 2026-05-10T18:59:20+00:00

I’m using FileStream to write to a file, and watching the underlying system calls

  • 0

I’m using FileStream to write to a file, and watching the underlying system calls using Process Monitor. I’m having trouble with some file locking issues in a production deployment, so I’m looking at the details closely.

This sample code:

        using (FileStream fs = new FileStream('c:\\temp\\test.txt', FileMode.Create, FileAccess.Write, FileShare.Read))         {             fs.Write(new byte[] { 1, 2, 3, 4, 5 }, 0, 5);             fs.Close();         } 

Causes the following systems calls:

9:27:09.4561092 AM  ConsoleApplication1.vshost.exe  2320    CreateFile  C:\temp\test.txt    SUCCESS Desired Access: Generic Read/Write, Disposition: OverwriteIf, Options: Synchronous IO Non-Alert, Non-Directory File, Open No Recall, Attributes: n/a, ShareMode: Read, AllocationSize: 0, OpenResult: Overwritten 9:27:12.2217409 AM  ConsoleApplication1.vshost.exe  2320    WriteFile   C:\temp\test.txt    SUCCESS Offset: 0, Length: 5 9:27:12.2219901 AM  ConsoleApplication1.vshost.exe  2320    CloseFile   C:\temp\test.txt    SUCCESS  9:27:12.2234484 AM  ConsoleApplication1.vshost.exe  2320    CreateFile  C:\temp\test.txt    SUCCESS Desired Access: Generic Read, Write Attributes, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Complete If Oplocked, Random Access, Attributes: N, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened 9:27:12.2248664 AM  ConsoleApplication1.vshost.exe  2320    QueryBasicInformationFile   C:\temp\test.txt    SUCCESS CreationTime: 10/29/2008 9:04:14 AM, LastAccessTime: 10/29/2008 9:27:12 AM, LastWriteTime: 10/29/2008 9:27:12 AM, ChangeTime: 10/29/2008 9:27:12 AM, FileAttributes: A 9:27:12.2250075 AM  ConsoleApplication1.vshost.exe  2320    SetBasicInformationFile C:\temp\test.txt    SUCCESS CreationTime: -1, LastAccessTime: -1, LastWriteTime: -1, ChangeTime: -1, FileAttributes: n/a 9:27:12.2255889 AM  ConsoleApplication1.vshost.exe  2320    QueryStandardInformationFile    C:\temp\test.txt    SUCCESS AllocationSize: 8, EndOfFile: 5, NumberOfLinks: 1, DeletePending: False, Directory: False 9:27:12.2257571 AM  ConsoleApplication1.vshost.exe  2320    ReadFile    C:\temp\test.txt    SUCCESS Offset: 0, Length: 5 9:27:12.2259825 AM  ConsoleApplication1.vshost.exe  2320    ReadFile    C:\temp\test.txt    SUCCESS Offset: 0, Length: 5 9:27:12.2261588 AM  ConsoleApplication1.vshost.exe  2320    ReadFile    C:\temp\test.txt    SUCCESS Offset: 0, Length: 5 9:27:12.2265161 AM  ConsoleApplication1.vshost.exe  2320    ReadFile    C:\temp\test.txt    SUCCESS Offset: 0, Length: 2 9:27:12.2268237 AM  ConsoleApplication1.vshost.exe  2320    ReadFile    C:\temp\test.txt    SUCCESS Offset: 0, Length: 5 9:27:12.2271332 AM  ConsoleApplication1.vshost.exe  2320    ReadFile    C:\temp\test.txt    SUCCESS Offset: 0, Length: 5 9:27:12.2272841 AM  ConsoleApplication1.vshost.exe  2320    ReadFile    C:\temp\test.txt    SUCCESS Offset: 0, Length: 5 9:27:12.2274779 AM  ConsoleApplication1.vshost.exe  2320    ReadFile    C:\temp\test.txt    SUCCESS Offset: 0, Length: 5 9:27:12.2276249 AM  ConsoleApplication1.vshost.exe  2320    ReadFile    C:\temp\test.txt    SUCCESS Offset: 0, Length: 5 9:27:12.2278766 AM  ConsoleApplication1.vshost.exe  2320    ReadFile    C:\temp\test.txt    SUCCESS Offset: 0, Length: 5 9:27:12.2282577 AM  ConsoleApplication1.vshost.exe  2320    ReadFile    C:\temp\test.txt    SUCCESS Offset: 0, Length: 5 9:27:12.2284476 AM  ConsoleApplication1.vshost.exe  2320    QueryFileInternalInformationFile    C:\temp\test.txt    SUCCESS IndexNumber: 0x2d000000016b88 9:27:12.2286183 AM  ConsoleApplication1.vshost.exe  2320    CloseFile   C:\temp\test.txt    SUCCESS  9:27:12.2288759 AM  ConsoleApplication1.vshost.exe  2320    CreateFile  C:\temp\test.txt    SUCCESS Desired Access: Read Attributes, Write Attributes, Disposition: Open, Options: , Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened 9:27:12.2305722 AM  ConsoleApplication1.vshost.exe  2320    QueryBasicInformationFile   C:\temp\test.txt    SUCCESS CreationTime: 10/29/2008 9:04:14 AM, LastAccessTime: 10/29/2008 9:27:12 AM, LastWriteTime: 10/29/2008 9:27:12 AM, ChangeTime: 10/29/2008 9:27:12 AM, FileAttributes: A 9:27:12.2307379 AM  ConsoleApplication1.vshost.exe  2320    CloseFile   C:\temp\test.txt    SUCCESS  

The first three IO calls are expected (create, write, close), but the the process goes on to read the file a dozen more times and repeatedly open and close it.

I’ve now observed this behavior on Win XP SP2, and Win 2003 x64. However, my Windows Vista machine at home behaves as expected (just the first three lines).

Any clues on why this is happening on non-Vista runtimes?

  • 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. 2026-05-10T18:59:21+00:00Added an answer on May 10, 2026 at 6:59 pm

    One possibility is that you have a virus scanner installed that injects itself into each running process?

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

Sidebar

Ask A Question

Stats

  • Questions 263k
  • Answers 263k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use the $end$ variable as shown in the following "if"… May 13, 2026 at 11:56 am
  • Editorial Team
    Editorial Team added an answer Don't think about unit tests, think about the behaviour you… May 13, 2026 at 11:56 am
  • Editorial Team
    Editorial Team added an answer You can continue you use math.h :) Just #include <math.h> May 13, 2026 at 11:56 am

Related Questions

I want use html5's new tag to play a wav file (currently only supported
In order to apply a triggered animation to all ToolTip s in my app,
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I've got a string that has curly quotes in it. I'd like to replace

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.