Process.Start returns null

前端 未结 4 1341
情深已故
情深已故 2020-12-16 12:05

i am writing a program that launches a random file in a directory. the file can be of any time, but mostly video or image files. each time i launch a file i want to close th

4条回答
  •  借酒劲吻你
    2020-12-16 12:11

    You are declaring 'proc' at method scope, so of course it will always be null when checked at the top of that method. If you want the reference to live beyond the function, declare it is a class level variable.

    You are spawning a process each time (probably), Process.Start is not returning null, but you simply lose the reference to it when i goes out of scope.

提交回复
热议问题