我正在使用以下代码尝试从 UNC 路径将大文件 (280Mb) 读入字节数组
public void ReadWholeArray(string fileName, byte[] data)
{
int offset = 0;
int remaining = data.Length;
log.Debug("ReadWholeArray");
FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
while (remaining > 0)
{
int read = stream.Read(data, offset, remaining);
if (read <= 0)
throw new EndOfStreamException
(String.Format("End of stream reached with {0} bytes left to read", remaining));
remaining -= read;
offset += read;
}
}
这与以下错误有关。
System.IO.IOException: Insufficient system resources exist to complete the requested
如果我使用本地路径运行它,它工作正常,在我的测试用例中,UNC 路径实际上指向本地框。
有什么想法吗?