I have many Windows CE 5 devices in the field, running our software.
Part of their duty is to zip up some directories, and send to the server.
On about 3 (of several hundred) devices, I get this error, consistently, when trying to zip up a directory. The zipping process involves descending through every subdirectory and adding the files.
System.IO.IOException: IOException
at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.Directory.InternalGetFileDirectoryNames(String fullPath, Boolean file)
at System.IO.Directory.InternalGetDirectories(String path, String searchPattern)
at System.IO.Directory.GetDirectories(String path, String searchPattern)
This happens every time on this device – not random.
Copying the directory contents to my development device, and running the same (on the same directory contents) does NOT cause the error. I do not have the actual device to debug interactively.
Of course, this WinIOError is not very useful in terms of determining actual cause. Can anyone give me any hints as to what could cause the CF to fail so spectacularly when just trying to read the directory contents?
As you can see below, common things like the directory no longer existing are handled by a specific exception to that effect – not the generic WinIOError.
Many thanks for any clues.
Below is the disassembled function:
// System.IO.Directory
internal static string[] InternalGetFileDirectoryNames(string fullPath, bool file)
{
char c = fullPath[fullPath.Length - 1];
if (c == Path.DirectorySeparatorChar || c == Path.AltDirectorySeparatorChar || c == Path.VolumeSeparatorChar)
{
fullPath += '*';
}
string[] array = new string[10];
int num = 0;
HostNative.FIND_DATA fIND_DATA = new HostNative.FIND_DATA();
if (!Directory.Exists(Path.GetDirectoryName(fullPath)))
{
throw new DirectoryNotFoundException();
}
int handle;
int num2 = PAL.File_OpenAndReadDir(fullPath, out handle, fIND_DATA);
if (num2 != 0)
{
if (num2 == -2147479552 || num2 == -2147479545)
{
return new string[0];
}
__Error.WinIOError(num2, Path.GetDirectoryName(fullPath));
}
int num3 = 0;
do
{
bool flag;
if (file)
{
flag = (0 == (fIND_DATA.dwFileAttributes & 16));
}
else
{
flag = (0 != (fIND_DATA.dwFileAttributes & 16));
if (flag && (fIND_DATA.cFileName.Equals(".") || fIND_DATA.cFileName.Equals("..")))
{
flag = false;
}
}
if (flag)
{
num3++;
if (num == array.Length)
{
string[] array2 = new string[array.Length * 2];
Array.Copy(array, 0, array2, 0, num);
array = array2;
}
array[num++] = fIND_DATA.cFileName;
}
num2 = PAL.File_ReadDir(handle, fIND_DATA);
}
while (num2 == 0);
PAL.File_CloseDir(handle);
if (num2 != 0 && num2 != -2147479545)
{
__Error.WinIOError(num2, Path.GetDirectoryName(fullPath));
}
if (!file && num3 == 1 && (fIND_DATA.dwFileAttributes & 16) != 0)
{
return new string[]
{
fIND_DATA.cFileName
};
}
if (num == array.Length)
{
return array;
}
string[] array3 = new string[num];
Array.Copy(array, 0, array3, 0, num);
return array3;
}
Physically broken storage media might cause this. Low quality SD card, by any chance?