繁体   English   中英

StreamWriter生成IOException无法找到指定的文件

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM