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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:13:01+00:00 2026-06-02T12:13:01+00:00

I am using a library that recursively scans really fast the files and directories

  • 0

I am using a library that recursively scans really fast the files and directories of a folder. The output is a List<WIN32_FIND_DATAW> . Click here to see the contents of the stuct.

I managed to convert FILETIME to DateTime with the following extension method:

public static DateTime convertToDateTime(this System.Runtime.InteropServices.ComTypes.FILETIME time)
{
    ulong high = (ulong)time.dwHighDateTime;
    int low = time.dwLowDateTime;
    uint uLow = (uint)low;
    high = high << 32;
    return DateTime.FromFileTime((long)(high | (ulong)uLow));
}

and I get the file size as:

  (UInt64)((nFileSizeHigh * (2 ^ 32)) + nFileSizeLow);

I find those methods online don’t recall where.

Anyways the library contains a method that requires a list of WIN32_FIND_DATA. I want to call that method but I don’t know how to create a WIN32_FIND_DATA object

Here is a random WIN32_FIND_DATA object created when I iterated through my C:\ Drive

enter image description here

How could I construct the same object? I don’t know how to get the cAlternateName although I don’t think I need that. I don’t know how to go back and convert a DateTime to FILETIME. Lastly I don’t know how to convert a file size into nFileSizeHigh and nFileSizeLow.


the library used this methods in order to constuct the WIN32_FIND_DATAW objects:

        [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
        public static extern IntPtr FindFirstFileW(string lpFileName, out WIN32_FIND_DATAW lpFindFileData);

        [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
        public static extern bool FindNextFile(IntPtr hFindFile, out WIN32_FIND_DATAW lpFindFileData);

        [DllImport("kernel32.dll")]
        public static extern bool FindClose(IntPtr hFindFile); 

Maybe there exists a public static extern bool FindFile(IntPtr hFindFile, out WIN32_FIND_DATAW lpFindFileData); method. so that I can construct the WIN32_FIND_DATAW objects that I need.


Edit

In short I want to construct a WIN32_FIND_DATAW object by having the full path of a file

  • 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-02T12:13:03+00:00Added an answer on June 2, 2026 at 12:13 pm

    Here is the declaration of necessary structures.

    public struct FILETIME
    {
         public UInt32 dwLowDateTime;
         public UInt32 dwHighDateTime;
    }
    
    public unsafe struct WIN32_FIND_DATAW
    {
        public UInt32 dwFileAttributes;
        public FILETIME ftCreationTime;
        public FILETIME ftLastAccessTime;
        public FILETIME ftLastWriteTime;
        public UInt32 nFileSizeHigh;
        public UInt32 nFileSizeLow;
        public UInt32 dwReserved0;
        public UInt32 dwReserved1;
        public fixed Char cFileName[256];
        public fixed Char cAlternateFileName[14];
    }
    

    You can construct and initialize such object as usual structure in C#.

    Update:
    The 64-bit integer stored in FILETIME structure represents the number of 100-nanosecond intervals since January 1, 1601 (UTC). In .NET DateTime.Ticks represents the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001. So, to convert DateTime to FILETIME you just need to subtract 1600 years from DateTime and write number of ticks as pair of unsigned 32-bit integers. Or you can just call DateTime.ToFileTimeUtc():

    FILETIME fileTime = new FILETIME();
    Int64 ticks = DateTime.Now.ToFileTimeUtc();
    fileTime.dwLowDateTime = (UInt32)ticks;
    fileTime.dwHighDateTime = (UInt32)(ticks >> 32);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a library that requires me to pass an Uri object as parameter.
I am using a library that prints a bunch of superfluous information to the
I'm using a library that defines an interface: template<class desttype> void connect(desttype* pclass, void
I need some help on compiler flags in c++. I'm using a library that
Using the D3DX library that is a part of directX, specifically directx9 in this
I am using a charting javascript library that expects its data in a specific
I have a C++ library that I build using Scons which is eventually linked
I am running some tests for extjs library that we are using in our
I'm trying to modify a python library that I downloaded and am using. But
I am writing a Win32 DLL library that can be redistributed. I am using

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.