本文介绍了在c#中访问ms word应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Cannot activate application
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: Cannot activate application
i我正在尝试打开一个c#中的word文档。但我的努力是徒劳的。请为我提供更好的解决方案。提前谢谢
i am trying to open a word document in c#. but my hard efforts were in vain. kindly provide me a better solution that works. thanks in advance
推荐答案
using System;
using System.Windows.Forms;
using System.Diagnostics;
namespace Open_Word_Document
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
void Button1Click(object sender, EventArgs e)
{
string filePath = "MyDocument.txt";// enter correct path to file with correct extension
Process open = new Process();
open.StartInfo.FileName = filePath;
open.Start();
open.Dispose();
}
}
}
这篇关于在c#中访问ms word应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!