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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:41:30+00:00 2026-06-11T20:41:30+00:00

I am implementing an event handler that must open and process the content of

  • 0

I am implementing an event handler that must open and process the content of a file created by a third part application over which I have no control. I am warned by a note in “C# 4.0 in a nutshell” (page 495) about the risk to open a file before it is fully populated; so I am wondering how to manage this occurrence. To keep at minimum the load on the event handler, I am considering to have the handler simply insert in a queue the file names and then to have a different thread to manage the processing, but, anyways, how may I make sure that the write is completed and the file read is safe? The file size could be arbitrary.

Some idea? Thanks

  • 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-06-11T20:41:31+00:00Added an answer on June 11, 2026 at 8:41 pm

    A reliable way to achieve what you want might be to use FileSystemWatcher + NTFS USN journal.
    Maybe more complicated than you expected, but FileSystemWatcher alone won’t tell you for sure that the newly created file has been closed

    -first, the FileSystemWatcher, to know when a file is created. From there you have the complete file path, and are 1 or 2 pinvokes away from getting the file unique ID (which can help you to track it during its whole lifetime).

    -then, read the USN journal, which tracks everything that occurs on your drive. Filter on entries corresponding to your new file’s ID, and read the journal until reaching the entry with the ‘Close’ event.

    From there, unless your file is manipulated in special ways (opened and closed multiple times by the application that generates it), you can assume it is safe to read it and do whatever you wanted to do with it.

    A really great C# implementation of an USN journal parser is StCroixSkipper’s work, available here:
    http://mftscanner.codeplex.com/

    If you are interested I can give you more help about USN journal, as I use it in my project.

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

Sidebar

Related Questions

In .NET, if I'm implementing an interface that contains an event, but that event
We are implementing a SOA-architecture the Udi Dahan way, which means that services are
My scenario is as follows: I am implementing a server that must timeout or
I have an application that contains a main Activity, which has a very simple
I'm implementing an event system for a game. It uses an event queue, and
I've spent many many hours tonight reading up on implementing the event-based asynchronous pattern
I meet are having difficulty in implementing a simple event OnCheckedChanged for control checkBox
I am implementing a CSS3 transition effect on a article element but the event
I'm implementing a listener class which listens for some events and then processes them.
I'm creating a shopping cart application and I'm having some issues with implementing a

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.