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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:10:14+00:00 2026-05-15T22:10:14+00:00

My application checks on startup if there is a newer version of a file

  • 0

My application checks on startup if there is a newer version of a file on a shared network drive. If the one on the network share is newer it copies it to the local application directory and overwrites the old one. My current code to do this goes something like this:

FileInfo sourceFile = new FileInfo(source + "\\" + fileName);
if(sourceFile.Exists) {
    FileInfo destFile = new FileInfo(destination + "\\" + fileName);
    if (destFile.Exists && destFile.LastWriteTime >= sourceFile.LastWriteTime)
    {
        //Using log4net
        log.Info("Current " + fileName + " is newer than the one on the server.");
        return false;
    }
}

Checking the logs, it seems that sometimes the LastWriteTime of the source file is not being detected as newer (event when it is). Am I possibly getting write times and modified times confused? Does anybody have an idea of how to achieve this?

EDIT (and copy of my comment below):
The files I am copying are mostly DLL files which I have control over. They are assemblies for the application “Growl for Windows”; they define custom displays. The intent of my application is to check the network share to see if there is a newer version available and to copy that locally if required. That way, we can help to ensure that all our clients are using the most up-to-date display.

EDIT 2:

OK, I fooled around with loading the assemblies, and I ran into another problem. It seems you cannot load the same file twice, even if they are from different locations, when they’re loaded via Assembly.ReflectionOnlyLoadFrom.

  • 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-15T22:10:14+00:00Added an answer on May 15, 2026 at 10:10 pm

    The docs for LastWriteTime do note that the value returned may not be accurate. Note the comment about the Refresh method as well – whilst the code above would almost certainly not require this to be called, if you’re creating FileInfo objects and holding onto them for any length of time this may be applicable.

    Windows is at liberty to delay updating the actual last write time for a file – as to how long this may be delayed for, check into the Windows API calls dealing with file information.

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

Sidebar

Related Questions

I have created a function in an application that checks for username and password
Application launch through Java web start(JWS) checks for update when we are launching it.
I have one demo application to check select for update query public class Test
If my application starts, I check first if there is already an instance of
I have an application that is installed per-machine (since it uses a service). One
I have a PowerShell script that checks that a certain directory is on the
Is there a reliable method to check if an application is run from somewhere
I have an application that on a subsequent start detects if there's a process
I have a Windows Forms application that currently loads a database on startup. The
I am writing an application that has a very loosely defined config file that

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.