What’s the difference between Process and ProcessStartInfo in C#?

前端 未结 2 899
轻奢々
轻奢々 2021-01-02 00:33

What’s the difference between Process and ProcessStartInfo? I’ve used both to launch external programs but there has to be a reason there are two w

2条回答
  •  清歌不尽
    2021-01-02 01:02

    Heh.

    If you look closely at your code, you will note that they are both using the same classes. The StartInfo property in your first example is, unsurprsingly, a ProcessStartInfo. In your second example, you call the static .Start method on the Process class.

    So what are the differences? Significant. They're different classes. One is for launching processes, one is for saying which process to launch (and lots of other little things, like capturing output, etc). In the first case, you just use the default ProcessStartInfo property that the class has.

提交回复
热议问题