J
Jody Gelowitz
Has anybody gotten the CeFindAllFiles API call to work? If so, how? I am
trying to use this to retrieve a list of directories or files and have not
been able to get anything. The connection with the device is active as I am
able to transfer files to the PC if I know the file path ahead of time.
Here is what I have:
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
internal static extern int CeFindAllFiles(string szPath, uint dwFlags, ref
int lpdwFoundCount,ref CE_FIND_DATA[] ppFindDataArray);
[StructLayout(LayoutKind.Sequential)]
public struct CE_FIND_DATA
{
public uint dwFileAttributes;
public int ftCreationTime;
public int ftCreationTime2;
public int ftLastAccessTime;
public int ftLastAccessTime2;
public int ftLastWriteTime;
public int ftLastWriteTime2;
public int nFileSizeHigh;
public int nFileSizeLow;
public int dwOID;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=260)] public string cFileName;
}
public enum RAPIFileAttributes : uint
{
ReadOnly = 0x0001,
Hidden = 0x0002,
System = 0x0004,
Directory = 0x0010,
Archive = 0x0020,
InROM = 0x0040,
Normal = 0x0080,
Temporary = 0x0100,
Sparse = 0x0200,
ReparsePt = 0x0400,
Compressed = 0x0800,
ROMModule = 0x2000
}
public CE_FIND_DATA[] GetAllFiles(string p_strStartPath, bool
p_bolGetDirectories)
{
CE_FIND_DATA[] retData = new CE_FIND_DATA[1];
RAPIFileAttributes intFlags;
int intFound=0;
int ret=0;
if(p_bolGetDirectories)
{
intFlags = RAPIFileAttributes.Directory;
}
else
{
intFlags = RAPIFileAttributes.Normal;
}
uint uintFlag;
uintFlag=(uint)intFlags;
ret=CeFindAllFiles(p_strStartPath, uintFlag, ref intFound, ref retData);
if(ret == 0)
{
throw new Exception("Could not get file attributes");
}
return retData;
}
Thanks,
Jody
trying to use this to retrieve a list of directories or files and have not
been able to get anything. The connection with the device is active as I am
able to transfer files to the PC if I know the file path ahead of time.
Here is what I have:
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
internal static extern int CeFindAllFiles(string szPath, uint dwFlags, ref
int lpdwFoundCount,ref CE_FIND_DATA[] ppFindDataArray);
[StructLayout(LayoutKind.Sequential)]
public struct CE_FIND_DATA
{
public uint dwFileAttributes;
public int ftCreationTime;
public int ftCreationTime2;
public int ftLastAccessTime;
public int ftLastAccessTime2;
public int ftLastWriteTime;
public int ftLastWriteTime2;
public int nFileSizeHigh;
public int nFileSizeLow;
public int dwOID;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=260)] public string cFileName;
}
public enum RAPIFileAttributes : uint
{
ReadOnly = 0x0001,
Hidden = 0x0002,
System = 0x0004,
Directory = 0x0010,
Archive = 0x0020,
InROM = 0x0040,
Normal = 0x0080,
Temporary = 0x0100,
Sparse = 0x0200,
ReparsePt = 0x0400,
Compressed = 0x0800,
ROMModule = 0x2000
}
public CE_FIND_DATA[] GetAllFiles(string p_strStartPath, bool
p_bolGetDirectories)
{
CE_FIND_DATA[] retData = new CE_FIND_DATA[1];
RAPIFileAttributes intFlags;
int intFound=0;
int ret=0;
if(p_bolGetDirectories)
{
intFlags = RAPIFileAttributes.Directory;
}
else
{
intFlags = RAPIFileAttributes.Normal;
}
uint uintFlag;
uintFlag=(uint)intFlags;
ret=CeFindAllFiles(p_strStartPath, uintFlag, ref intFound, ref retData);
if(ret == 0)
{
throw new Exception("Could not get file attributes");
}
return retData;
}
Thanks,
Jody