我正在通過Asp.Net開發一些頁面,其中包含打開和閱讀一些MS Word文檔,它在我自己的本地主機上運行良好,但是當我將文件在wwwroot下並運行Inetmgr頁面出現此錯誤:在IIS 7中打開MS Word文檔時出現錯誤,
此命令不可用,因爲沒有文檔處於打開狀態。
您認爲問題出在哪裏?我應該在IIS管理器中添加一些引用或編輯一些設置以使用MS Word文檔?怎麼樣?謝謝:)
,這是如何我試圖打開和讀取文檔稱爲stopwords.doc
static extractor()
{
try
{
ApplicationClass wordApp = new ApplicationClass();
string[] words;
char[] delimiterChars = { ' ', ',', '.', '\r', '\t', '\n' };
string filePath = "http://localhost:8777/stopwords.doc";
object file = filePath;
object nullobj = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(ref file,
ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj,
ref nullobj);
Microsoft.Office.Interop.Word.Document doc1 = wordApp.ActiveDocument;
string m_Content = doc1.Content.Text;
doc.Close(ref nullobj, ref nullobj, ref nullobj);
if (m_Content != null)
{
words = m_Content.Split(delimiterChars);
foreach (string s in words)
{
if (!stopwords.ContainsKey(s))
stopwords.Add(s, s);
}
}
}
catch (Exception)
{
throw;
}
}
你如何打開你的文檔?你可以顯示代碼嗎? –
我要麼從用戶處理文檔或處理服務器上的一些已知文件 – ePezhman