.NET 4.x Как загружать файл из программы, не меняя код? - C#
Формулировка задачи:
Word.Application app = new Word.Application();
//---------------------------------------------------------------------------------------------------------------------
Object fileName = @"C:\Users\JPro.JPro-ПК\Desktop\WordToXpsDocument\4 глава.docx";
// --------------------------------------------------------------------------------------------------------------------
Object missing = Type.Missing;
app.Documents.Open(ref fileName);
Word.Find find = app.Selection.Find;
string[] array = new string[2];
string[] array1 = new string[2];
array[0] = textBox1.Text;
array1[0] = textBox2.Text;
for (int i = 0; i < array.Length; i++)
{
find.Text = array[i];
find.Replacement.Text = array1[i];
Object wrap = Word.WdFindWrap.wdFindContinue;
Object replace = Word.WdReplace.wdReplaceAll;
find.Execute(FindText: Type.Missing,
MatchCase: false,
MatchWholeWord: false,
MatchWildcards: false,
MatchSoundsLike: missing,
MatchAllWordForms: false,
Forward: true,
Wrap: wrap,
Format: false,
ReplaceWith: missing, Replace: replace);
}
app.ActiveDocument.Save();
app.ActiveDocument.Close();
app.Quit();Object fileName = @"C:\Users\JPro.JPro-ПК\Desktop\WordToXpsDocument\4 глава.docx";
Решение задачи: «.NET 4.x Как загружать файл из программы, не меняя код?»
textual
Листинг программы
string fileName = Console.ReadLine();