我在现场有许多运行我们的软件的Windows CE5设备。
他们的部分职责是压缩一些目录,并发送到服务器。
在大约3台(共数百台)设备上,当我试图压缩目录时,我总是得到这个错误。压缩过程包括向下遍历每个子目录并添加文件。
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)这在这个设备上每次都会发生--不是随机的。
将目录内容复制到我的开发设备,并运行相同的(在相同的目录内容上)不会导致错误。我没有可以交互调试的实际设备。
当然,就确定实际原因而言,此WinIOError并不是很有用。谁能给我一些提示,说明是什么原因导致CF在试图读取目录内容时出现如此严重的故障?
正如您在下面看到的,目录不再存在这样的常见情况是由一个特定的异常来处理的,而不是通用的WinIOError。
非常感谢你提供的任何线索。
下面是反汇编的函数:
// 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;
}发布于 2011-07-04 17:58:09
物理损坏的存储介质可能会导致此问题。有没有可能是低质量的SD卡?
https://stackoverflow.com/questions/6569821
复制相似问题