我收到以下错误:
无法创建类 TestProject.TestClass 的实例。错误:System.Runtime.InteropServices.COMException:找不到“D:\Automation\TestProject\OBJECT_DEFINITIONS.XLS”。检查文件名的拼写,并验证文件位置是否正确。如果您尝试从最近使用的文件列表中打开该文件,请确保该文件未被重命名、移动或删除。
错误堆栈跟踪:
Microsoft.Office.Interop.Excel.Workbooks.Open(字符串文件名、对象 UpdateLinks、对象只读、对象格式、对象密码、对象 WriteResPassword、对象 IgnoreReadOnlyRecommended、对象来源、对象分隔符、对象可编辑、对象通知、对象转换器、对象 AddToMru , 对象本地, 对象 CorruptLoad)
TestProject.TestLibrary.GetObjectDeclarations(String sModule) 在 C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\TestProject\TestLibrary.cs: 第 133 行
TestProject.TestClass..ctor( ) 在 C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\TestProject\TestClass.cs:第 51 行
代码:
using Excel = Microsoft.Office.Interop.Excel;
namespace TestProject
{
[TestClass]
public class TestLibrary
{
public string[] arrObj = new string[19];
public string[] arrConfig = new string[12];
public string sobjfile;
.
.
.
xlApp = new Excel.Application();
xlWorkBook = xlApp.Workbooks.Open(sobjfile, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
我想知道为什么D:\Automation\TestProject\OBJECT_DEFINITIONS.XLS
当我OBJECT_DEFINITIONS.XLS
存储在C:\