为什么错误提示是:错误 CS0102: 类型“WindowsFormsApplication2.dlWindow”已经包含“openFile”的定义 请各位大侠看看错在哪里,如何修改?小弟不胜感激public override void openFile(object fileName)
{
try
{
{ object file = openFileDialog1.FileName; object nullobj = System.Reflection.Missing.Value; object filename = file; object confirmConversions = Type.Missing; object readOnly = Type.Missing; object addToRecentFiles = Type.Missing; object passwordDocument = Type.Missing; object passwordTemplate = Type.Missing; object revert = Type.Missing; object writePasswordDocument = Type.Missing; object writePasswordTemplate = Type.Missing; object format = Type.Missing; object encoding = Type.Missing; object visible = Type.Missing; object openConflictDocument = Type.Missing; object openAndRepair = Type.Missing; object documentDirection = Type.Missing; object noEncodingDialog = Type.Missing; object missing = Type.Missing; Microsoft.Office.Interop.Word.ApplicationClass wordApp = new ApplicationClass(); Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(ref filename,
ref confirmConversions,
ref readOnly,
ref addToRecentFiles,
ref passwordDocument,
ref passwordTemplate,
ref revert,
ref writePasswordDocument,
ref writePasswordTemplate,
ref format,
ref encoding,
ref visible,
ref openConflictDocument,
ref openAndRepair,
ref documentDirection,
ref noEncodingDialog);
}
}
catch (Exception ex)
{
MessageBox.Show("出现错误:" + ex.ToString());
}private void BtnRead_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
object file = openFileDialog1.FileName; openFile(file);
readPar(1);
doc.ActiveWindow.Selection.WholeStory();
doc.ActiveWindow.Selection.Copy(); IDataObject data = Clipboard.GetDataObject();
doc.Activate(); doc.Close(ref missing, ref missing, ref missing); richTextBox1.Text = data.GetData(DataFormats.Text).ToString();
}
{
try
{
{ object file = openFileDialog1.FileName; object nullobj = System.Reflection.Missing.Value; object filename = file; object confirmConversions = Type.Missing; object readOnly = Type.Missing; object addToRecentFiles = Type.Missing; object passwordDocument = Type.Missing; object passwordTemplate = Type.Missing; object revert = Type.Missing; object writePasswordDocument = Type.Missing; object writePasswordTemplate = Type.Missing; object format = Type.Missing; object encoding = Type.Missing; object visible = Type.Missing; object openConflictDocument = Type.Missing; object openAndRepair = Type.Missing; object documentDirection = Type.Missing; object noEncodingDialog = Type.Missing; object missing = Type.Missing; Microsoft.Office.Interop.Word.ApplicationClass wordApp = new ApplicationClass(); Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(ref filename,
ref confirmConversions,
ref readOnly,
ref addToRecentFiles,
ref passwordDocument,
ref passwordTemplate,
ref revert,
ref writePasswordDocument,
ref writePasswordTemplate,
ref format,
ref encoding,
ref visible,
ref openConflictDocument,
ref openAndRepair,
ref documentDirection,
ref noEncodingDialog);
}
}
catch (Exception ex)
{
MessageBox.Show("出现错误:" + ex.ToString());
}private void BtnRead_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
object file = openFileDialog1.FileName; openFile(file);
readPar(1);
doc.ActiveWindow.Selection.WholeStory();
doc.ActiveWindow.Selection.Copy(); IDataObject data = Clipboard.GetDataObject();
doc.Activate(); doc.Close(ref missing, ref missing, ref missing); richTextBox1.Text = data.GetData(DataFormats.Text).ToString();
}
错误提示的是openFile重复定义了,看看你代码中是不是Partial类或者其它地方还有openFile的定义。