Wordで開いているときにアクティブなWordドキュメントのbase64表現を取得しようとすると、ReadAllBytes()で次のエラーが発生します。
プロセスは、別のプロセスによって使用されているファイル「ファイルパス」にアクセスできません
public string GetEncodedTemplate()
{
//Convert a Word document's base64 representation
string base64 = String.Empty;
_application.ActiveDocument.Save();
string docPath = _application.ActiveDocument.FullName;
byte[] binarydata = File.ReadAllBytes(docPath);
base64 = System.Convert.ToBase64String(binarydata, 0, binarydata.Length);
return base64;
}
指定されたドキュメントがまだWordで開いているためにエラーが発生することを理解していますが、私の質問は-一時ファイルに保存せずにドキュメントのbase64表現を取得することはまだ可能ですか?
C#.NET4.0とMSOffice2010を使用しています