Hi! I used below code:
private void Load_Click(object sender, EventArgs e)
{
string[] filePaths = System.IO.Directory.GetFiles(@"C:\Documents\");
List<ListItem> files = new List<ListItem>();
foreach (string filePath in filePaths)
{
files.Add(new ListItem(System.IO.Path.GetFileName(filePath), filePath));
}
OpenWordFile(files.ToString());
}
private void OpenWordFile(string flName)
{
object noSave = false;
object missingVal = System.Reflection.Missing.Value;
object fileName = flName;
Microsoft.Office.Interop.Word._Application wordApp = new Microsoft.Office.Interop.Word.Application();
wordApp.Visible = false;
Microsoft.Office.Interop.Word._Document wordDoc;
wordDoc = wordApp.Documents.Open(ref fileName, ref missingVal, ref missingVal, ref missingVal, ref missingVal, ref missingVal, ref missingVal, ref missingVal, ref missingVal, ref missingVal, ref missingVal);
wordDoc.Select();
wordApp.Selection.Copy();
richTB.Text = string.Empty;
richTB.Paste();
wordDoc.Close(ref noSave, ref missingVal, ref missingVal);
wordApp.Quit(ref noSave, ref missingVal, ref missingVal);
}
But it’s not add and open multiple ms word files into richTextBox. Who is you can help me?