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
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.