1
我正在从磁盘加载我的文件,但出现错误:System.IO.IOException。从日志从C#中的磁盘加载文件 - System.IO.IOException
FileStream attachment;
using (var stream = File.Open(@"c:\testFolder\test.txt", FileMode.Open))
{
attachment = stream;
}
错误:
Exception thrown: 'System.IO.IOException' in System.IO.FileSystem.dll Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.ni.dll 2017-04-20 07:19:08 [Error] Invalid argument
该文件存在。
我在做什么错了?
我使用的是Asp.Net Core 1.1。
通常有一个额外的信息时,会抛出异常。你能分享吗? (调用'.getMessage()') – KarelG
你有权限访问该文件,该文件是否已经被另一个应用程序打开?显示异常消息。 – fubo
哪一行抛出异常?第二行或第四行? –