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
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