C# 错误System.Runtime.InteropServices.COMException,尽管文件存在

C# 错误System.Runtime.InteropServices.COMException,尽管文件存在,c#,excel,exception,office-interop,comexception,C#,Excel,Exception,Office Interop,Comexception,我一直试图通过控制台打开EXCEL文件,但每次都会出现以下异常: System.Runtime.InteropServices.COMException 文件不存在或丢失。路径正确。以下是我得到的异常代码: string path = @"C:\User\Desktop\TerritoryFile.xlsx"; var file = new Excel.Application(); file.Visible = false; var wb = file.Workbooks.Open(path);

我一直试图通过控制台打开EXCEL文件,但每次都会出现以下异常:

System.Runtime.InteropServices.COMException

文件不存在或丢失。路径正确。以下是我得到的异常代码:

string path = @"C:\User\Desktop\TerritoryFile.xlsx";
var file = new Excel.Application();
file.Visible = false;
var wb = file.Workbooks.Open(path);
除了错误的路径之外,可能还有其他原因吗

string path = @"your file path ";
var file = new Microsoft.Office.Interop.Excel.Application();
file.Visible = false;
var wb = file.Workbooks.Open(path);

当调试时,你们将鼠标悬停在路径上,你们看到了什么?另外,你们能再显示一些代码吗thanks@SimonPrice我看到了它应该是的路径。@SimonPrice我也在代码段中包含了它。如果您转到资源管理器窗口并尝试从那里打开文件,该路径是否确实存在?