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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:57:46+00:00 2026-05-22T14:57:46+00:00

Most of the files I read get the right time when using the following

  • 0

Most of the files I read get the right time when using the following method to convert:

// works great most of the time
private static DateTime convertToDateTime(System.Runtime.InteropServices.ComTypes.FILETIME time)
{
    long highBits = time.dwHighDateTime;
    highBits = highBits << 32;
    return DateTime.FromFileTimeUtc(highBits + time.dwLowDateTime);
}

Here I have an example in visual studio to show how this method sometimes does not work for example I will show the actual file in my computer and the debug. So the file that happens to be in my debug is:

“A:\Users\Tono\Documents\Visual Studio 2010\Projects\WpfApplication4\WpfApplication4\obj\x86\Debug\App.g.cs”
enter image description here

And here is the FILETIME that I am trying to convert to DateTime “I need the LastWriteTime by the way”

enter image description here

Here you can see that dwHighDateTime = 30136437 and also that dwLowDateTime = -2138979250 from that file.

And when I run my method plus other techniques I get the following dates:
enter image description here

So so far everything seems to be working great. But why is that that when I browse and look for that specific file in windows I get a different date !? Here is the date that I get when seeing the file’s properties:
enter image description here

Why does the dates don’t match? What am I doing wrong?

  • 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-22T14:57:47+00:00Added an answer on May 22, 2026 at 2:57 pm

    You need to combine the LS and MS values bitwise, not arithmetically.

    Try:

            ulong high = 30136437;
            unchecked
            {
                int low = -2138979250;
                uint uLow = (uint)low;
                high = high << 32;
                Date dt = DateTime.FromFileTime((long) (high | (ulong)uLow));
            }
    

    Or any of the following should work too:

    long highBits = time.dwHighDateTime;     
    highBits = highBits << 32;     
    
    return DateTime.FromFileTimeUtc(highBits + (long) (uint) time.dwLowDateTime); 
    
    return DateTime.FromFileTimeUtc(highBits | (long) (uint) time.dwLowDateTime); 
    
    return DateTime.FromFileTimeUtc(highBits + ((long)low & 0xFFFFFFFF))
    
    return DateTime.FromFileTimeUtc(highBits | ((long)low & 0xFFFFFFFF))
    

    You can get away with adding rather than a bitwise-or if you are sure the values are positive (and have no bits in common). But bitwise-or expresses the intent better.

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

Sidebar

Related Questions

I need to read smallish (few MB at the most, UTF-8 encoded) XML files,
The most common method for corrupting compressed files is to inadvertently do an ASCII-mode
I'm using JSLint to verify most of my external Javascript files, but the largest
I read some info regarding getting .h files for undocumented API. Most of sources
In most browsers, an input type=file has the following files property: document.getElementById(my-input).files This can
I'd like to read at most 20 lines from a csv file: rows =
I have a project folder with sources, headers, resources, etc. Most files are subject
Most of my C/C++ development involves monolithic module files and absolutely no classes whatsoever,
I'm trying to upload files within MVC. Most solution I saw on SO is
I need to download several files via http in Python. The most obvious way

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.