3
次のコードでは、2行目に "Exception from HRESULT:0x800A03EC"というエラーがスローされます。私はFullNameのためにnullを得ていると思う。誰かが私が間違っていることを教えてもらえますか?C#とOffice Interopを使用してOfficeドキュメントの完全なファイル名を取得するにはどうすればよいですか?
Foo.DataClasses1DataContext db = new Foo.DataClasses1DataContext();
string ThisDocument = Globals.ThisAddIn.Application.ThisWorkbook.FullName;
byte[] inputBuffer = System.IO.File.ReadAllBytes(ThisDocument);
Foo.RFP_Document rfpDocument = new MediaDesk.RFP_Document();
rfpDocument.DocumentName = "Foobar";
rfpDocument.DocumentFile = new System.Data.Linq.Binary(inputBuffer);
db.RFP_Documents.InsertOnSubmit(rfpDocument);
db.SubmitChanges();
コンテキストの場合、これはC#ターゲティング.NET 4.0で書かれたExcel 2010アドインです。コードの目的は、文書をデータベースに保存することです。