0

Visual Studio プロジェクトで Word ファイルを使用して編集し、ファイルを返したいと考えています。

Microsoft.Office.Interop.Word.Document tempDoc = null;
try
{
    object missing = System.Reflection.Missing.Value;
    Application wordApp = new Application();

    //I have a copy on C: and this works.
    object useFileName = "C:\\WordFile.doc";

    object readOnly = false;
    object isVisible = false;
    wordApp.Visible = false;
    tempDoc = wordApp.Documents.Open(ref useFileName, ref missing,
        ref missing, ref missing, ref missing, ref missing,
        ref missing, ref missing, ref missing, ref missing,
        ref missing, ref isVisible, ref missing, ref missing,
        ref missing, ref missing);
    ...
    }
    return tempDoc;

プロジェクト (Content/Documents/WordFile) で Word ドキュメントを参照するにはどうすればよいですか?

4

2 に答える 2

1

System.Reflection.Assembly.GetExecutingAssembly().Location; から実行中のコードの場所を取得できます。

または、構成ファイルにドキュメントの場所を配置します。

于 2013-01-25T14:44:19.350 に答える
1

おそらく、Server.MapPathwhich を使用して、物理ディレクトリにマップする相対パスまたは仮想パスを指定します。

Server.MapPath("~/Content/Documents/WordFile")
于 2013-01-25T14:38:05.187 に答える