2012-03-29 175 views
0

我有一個web應用程序,在上傳圖片時工作正常,但上傳較大的視頻到picasa時,我有時會收到錯誤消息。有沒有一種方法我可以知道蒸汽不再需要了,所以我可以關閉它(使用關鍵字「使用」或其他)感謝您的任何建議。 錯誤asp.net錯誤無法關閉流,直到寫入所有字節

System.Net.WebException:請求已中止:請求是 取消。 ---> System.IO.IOException:寫入所有 字節之前無法關閉流。

PicasaEntry entry = service.Insert(postUri, videoEntry);//This is the line that does the call 
       PhotoAccessor googlePhoto = new PhotoAccessor(entry); 
       stream.Close();//Fails here 
+2

需要的代碼一對夫婦多行;你能顯示你初始化流的位置以及你如何使用流?如果我沒有記錯,service.Insert的重載之一需要一個流對象... – dash 2012-03-29 21:29:18

回答

2

我不知道到底是什麼類型的流對象,但基本流類有,你可以打電話強制所有內容流中要寫入的沖洗方法。

stream.Flush(); 
stream.Close(); 

MSDN Documentation

+0

我會給這個嘗試,讓你知道發生了什麼謝謝 – user516883 2012-03-30 14:41:56

相關問題