c# - start a Process (executable) in Resources -
ive added executable file in resources, , when tried build project, got file not found exception [the system cannot find file specified].
here code
process sortprocess = new process(); byte[] connect = sample.properties.resources.connect; sortprocess.startinfo.filename = connect.tostring();
pls me. can try create own demo project, add executables in resources, start process.
thank ps: im trying access executable in resources embedded resource.
you need make sure file copied on build time.
in visual studio, right click on exe file in solution browser , go properties.
believe under "compile action" select "always copy" or that.
sorry don't have vs in front of me, there under properties.
edit sorry answered in kind of hurry. don't think can or should embed executables this. happening in code reading entire exe file, byte byte, string, ofcourse not result in filename.
embedded resources additional content images, text files , such.
to add .exe project, can drag'n'drop solution explorer. set 'build action' 'content' , 'copy output directory' 'always copy' or 'copy if newer'.
basic code running process be:
process p = new process(); p.startinfo.filename = "pathtoexe.exe" //can relative path p.start();
check documentation on process , processstartinfo more advanced options http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx
Comments
Post a Comment