[英]StreamWriter generate IOException Unable to find the specified file
我有以下代碼:
using (StreamWriter writer = new StreamWriter(filename, true))
{
writer.WriteLine(mydata);
}
有時會生成此錯誤: IOException.Message = "Unable to find the specified file"
。
文件名字符串由用戶指定,可以是網絡位置,例如:
\\mycorp\Shared\Data.xml
而且mydata
變量也是一個字符串。
此代碼是否有可能生成FileNotFoundException
?
問題“此代碼是否有可能生成FileNotFoundException
?”的答案。 沒有。
來源: https : //msdn.microsoft.com/en-us/library/36b035cb.aspx
我建議檢查異常來自何處。 它應該在異常堆棧跟蹤中給出一個行號。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.