我使用此代碼使用Web服務來讀取文件,無法打開文件
FileStream stream = File.OpenRead(FileName);
byte[] contents = new byte[stream.Length];
stream.Read(contents, 0, (int)stream.Length);
stream.Close();
,但我得到這個錯誤
System.Web.Services.Protocols.SoapException:服務器無法到 處理請求。 --->無法打開文件「fileName.pdf」。 --->不能 打開文件「filename.pdf」。在在 System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(字符串 方法名 System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage 消息,WebResponse的響應,流responseStream,布爾 asyncCall),對象[]參數)at
它是隨機的,有時它通過錯誤有時它不會。
代碼被200多個用戶使用,它只是隨機拋出異常。
'filename.pdf'不存在?或者至少不在服務所在的目錄中?嘗試將_entire_路徑包含到文件中。 –
此異常是否有內部異常? – Renan
@DStanley它隨機發生......並在下一刻工作。 – Mathematics