使用Process.Start在C#中打开一个文件

Mat*_*att 3 .net c# process.start winforms

我正在编写一个监视文件夹的程序,让您知道何时创建文件.当用户点击"确定"时,我很难打开文件.请问我有关于如何开始Process.Start()工作的建议,我正在尝试获取文件位置以从e.Fullpath记事本中加载文本文件并在其中打开.

private void fileSystemWatcher1_Changed(object sender, FileSystemEventArgs e)
{
    DialogResult messageresult = MessageBox.Show("You have a Collection Form: " + e.Name);
    if (messageresult == DialogResult.OK)
        Process.Start("Notepad.exe", "e.FullPath");
}
Run Code Online (Sandbox Code Playgroud)

小智 8

尝试 Process.Start("Notepad.exe", e.FullPath);


Ton*_*ion 6

Process.Start的第二个参数是一个字符串,但是您传递的是字符串类型,因此您不需要使用"周围的标记".

只有字符串文字(例如第一个参数)需要在它们周围加上引号.