[英]System.Threading.Tasks and FileStream
我正在嘗試使用FileStream對象從網絡上的其他文件讀取數據。 因此,我創建了任務(System.Threading.Tasks)來讀取所需文件的一部分。
的行為感到非常驚訝。 這些任務拋出錯誤:
int_ReadBytes = stm_BaseStream.Read (byt_buffer, 0, ( int ) ( int_RecordLength * uint_BufferThis ));
if (int_ReadBytes != ( int_RecordLength * uint_BufferThis ))
{
throw new Exception ("Could not read record");
// throws an error here.
}
是否有人將Task與FileStream對象一起使用,或者有任何想法為什么我遇到了這個問題? 謝謝。
int_ReadBytes
的返回值是int_ReadBytes
? 它可能不等於(int_RecordLength * uint_BufferThis)
僅是因為文件中沒有足夠的字節可讀取,這會導致代碼引發異常。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.