我正在使用C#写入桌面上的文件.关闭我的应用程序(关闭时)可以打开此文件(而不是双击它)吗?
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
writer.Close();
/* Some code here */
}
Run Code Online (Sandbox Code Playgroud)
根据OP的澄清评论,这里是,在记事本过程中打开文件:
Process.Start("notepad.exe", fileName);
Run Code Online (Sandbox Code Playgroud)
更新:
确保在打开记事本进程后立即"终止""父"进程,否则它将挂起@Kilazur注释掉:
Process.GetCurrentProcess().Kill(); // or Application.Exit(); or anything else
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1122 次 |
| 最近记录: |