How do I get the path of a binary in c#? -
for reporting purposes i'm trying location of binary. i doing this, , working, i'm getting nullreferenceexception when try testproc.mainmodule.filename; , think may program closing before i'm able grab it. there better way this? processstartinfo testpsi = new processstartinfo(runoptions.testbinary); testpsi.redirectstandarderror = true; testpsi.redirectstandardoutput = true; testpsi.useshellexecute = false; process testproc = new process(); testproc.startinfo = testpsi; testproc.start(); ret = testproc.mainmodule.filename; testproc.kill(); if (ret != null) return ret; option 1: use path have. unless i'm missing something, looks you're creating process (with runoptions.testbinary ), should know path. can full path executable path.getfullpath(runoptions.testbinary) , or if binary on path , can manually examine each directory determine binary being executed from. option 2: use c#'s wmi libraries: if there differences in bitness (32-...