This time I solved my problem myself. It seems the
FtpFindFirstFile API always returns ANSI but dotnet
automatically defaults to unicode when
CharSet=CharSet.Auto.
The declaration should thus be:
[StructLayout(LayoutKind.Sequential,
CharSet=CharSet.Ansi)]
public struct WIN32_FIND_DATA
{
public uint fileAttributes;
public fFILETIME creationTime;
public fFILETIME lastAccessTime;
public fFILETIME lastWriteTime;
public uint fileSizeHigh;
public uint fileSizeLow;
public uint reserved0;
public uint reserved1;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=260)]
public string fileName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=14)]
public string alternateFileName;
}
[DllImport("wininet.dll")]
static extern int FtpFindFirstFile (int hFtpSession,
string lpszSearchFile, out WIN32_FIND_DATA lpFindFileData,
int dwFlags, int dwContent);
Rudolf
-----Original Message-----
Sorry, another related question, what should the
declaration of
[StructLayout(LayoutKind.Sequential,
CharSet=CharSet.Auto)]public struct WIN32_FIND_DATA
{
public uint fileAttributes;
public fFILETIME creationTime;
public fFILETIME lastAccessTime;
public fFILETIME lastWriteTime;
public uint fileSizeHigh;
public uint fileSizeLow;
public uint reserved0;
public uint reserved1;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=260)]
public string fileName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=14)]
public string alternateFileName;
}
static extern int FtpFindFirstFile (int hFtpSession,
string lpszSearchFile, out WIN32_FIND_DATA
lpFindFileData,int dwFlags, int dwContent);
be for the WIN32_FIND_DATA structure to return the
filename property? I'm just getting nulls in the field
even though I tried initializing it before.
Thanks
Rudolf