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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:49:45+00:00 2026-06-16T04:49:45+00:00

I am getting the LastWriteTime of my executable and comparing it to an internal

  • 0

I am getting the “LastWriteTime” of my executable and comparing it to an internal DateTime that I have set. If the LastWriteTime is less than or equal to the internal DateTime then I will clear two tables from a database.

This code works great for me in the Pacific Time Zone. But if a user is in another time zone, (example 4 hours ahead of me), then it does not work because the “LastWriteTime” returns the time converted to their time zone. For example, I am looking for the value of “12/12/2012 8:38:12 AM” and if they are 4 hours ahead of me, this value gets automatically changed to “12/12/2012 12:38:12 PM” on their systems.

Can someone please show me what I should modify in my code to take into account for different time zones so the “LastWriteTime” and my ‘build2023_EXE_Date’ variable both return the same Date/Time so my comparision of the two date/time values don’t fail regardless of what time zone my end user is in?

I am using .NET 3.5, not .Net 4.x

//http://stackoverflow.com/questions/1600962/displaying-the-build-date
string w_file = "MyEXE.exe";
string w_directory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
                       Path.DirectorySeparatorChar + "MyEXE";

DateTime currentExeTime = File.GetLastWriteTime(System.IO.Path.Combine(w_directory, w_file));


DateTime build2023_EXE_Date = new DateTime(2012, 12, 12, 8, 38, 12); //"12/12/2012 8:38:12 AM"

//We need to truncate the millisecond time off of the EXE LastWriteTime
//or else when we compare to our internal DateTime build2323_EXE_Date value,
//it will not match
//http://stackoverflow.com/questions/1004698/how-to-truncate-milliseconds-off-of-a-net-datetime
currentExeTime = new DateTime(
     currentExeTime.Ticks - (currentExeTime.Ticks % TimeSpan.TicksPerSecond),
            currentExeTime.Kind
            );

if (currentExeTime <= build2023_EXE_Date) //If previous build matches or is before the Build 2023 date then clear these two tables.
{
    //This will fail the comparision if the user is in a different time zone than me.
    //Clear tables
}
  • 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-16T04:49:47+00:00Added an answer on June 16, 2026 at 4:49 am

    Use the DateTime ToUniversalTime() method

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

Sidebar

Related Questions

Getting the error here that says The import javax.servelt cannot be resolved I set
Getting extremely confused with an adminhtml module i'm trying to write! Effectively I have
Getting ERR_CONNECTION_RESET after more or less 2 minutes of uploading a rather big file
Getting red warning message that expected identifier for this statement CALayer = ImageView.layer; Using
Getting this weird LINQ error. title = System.Linq.Enumerable+WhereSelectEnumerableIterator`2[System.Xml.Linq.XElement,System.String Here is the code I have:
Getting the following error, which I understand and have seen before. But one thing
Getting this error: Each GROUP BY expression must contain at least one column that
Getting the time from a Wordpress post (the field being post_date_gmt stored in DATETIME),
Getting this error when I follow the simple code example from jsoncpp, that basically
Trying to set cache response headers on a dynamically-generated image, I'm getting a weird

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.