[StructLayout(LayoutKind.Explicit,CharSet=CharSet.Unicode)]
public struct CE_FIND_DATA
{
[FieldOffset( 0)] public uint dwFileAttributes;
[FieldOffset( 4)] public FILETIME ftCreationTime;
[FieldOffset( 12)] public FILETIME ftLastAccessTime;
[FieldOffset( 20)] public FILETIME ftLastWriteTime;
[FieldOffset( 28)] public uint nFileSizeHigh;
[FieldOffset( 32)] public uint nFileSizeLow;
[FieldOffset( 36)] public uint dwOID;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=260),FieldOffset(40)] public string Name;
};
Note :
FILETIME is now obsolet. You can use System.Runtime.InteropServices.ComTypes.FILETIME type instead.
<StructLayout(LayoutKind.Sequential, pack:=4, CharSet:=CharSet.Unicode)> _
Public Structure CE_FIND_DATA
Public dwFileAttributes As Integer
Public ftCreationTime As FILETIME
Public ftLastAccessTime As FILETIME
Public ftLastWriteTime As FILETIME
Public nFileSizeHigh As Integer
Public nFileSizeLow As Integer
Public dwOID As Integer
<MarshalAs(UnmanagedType.ByValTStr, sizeConst:=MAX_PATH)> _
Public cFileName As String
End Structure
None needed
MAX_PATH is set to 260 characters by Windows so we create a ByValTStr with this length. Can then just use the 'Name' field as a normal string
int hFile;
CE_FIND_DATA Data=new CE_FIND_DATA();
hFile=CeFindFirstFile("\\My Documents",ref Data);
return (hFile!=0);
Do you know one? Please contribute it!