Kill process started with System.Diagnostic.Process.Start(“FileName”)

后端 未结 6 1335
生来不讨喜
生来不讨喜 2021-02-05 22:48

I am trying to create an app that will perform actions on specific times (much like the Windows Task Scheduler). I am currently using Process.Start() to launch the file (or exe)

6条回答
  •  长发绾君心
    2021-02-05 23:14

    If you are letting the registered windows program to open the file, rather than picking the program you want. Then I advise you do not kill the process.

    The reason for this is what say your program does use the default application, but that application is already in use, and contains unsaved data. A user would not be happy for your program to overtake there application with the new file and then kill off the process that was already in use by the user for another purpose. Sure, it might not be in use but you must consider the worst case.

    As such, I recommend what has been suggested. use Process.Start() with the full path to the program to be used and the file to be opened.

提交回复
热议问题