.net - Defining a working directory for executing a program (C#) -



.net - Defining a working directory for executing a program (C#) -

i trying executable launched specific folder.

the code have below crashes application oddly enough:

process p = new process(); p.startinfo.workingdirectory = "dump"; p.startinfo.filename = s; p.start();

i debugged it, , saying can't find file start, file / folder defintly exists, syntax bad?

the code below works, working directroy not defined, can't find executable

process.start(@"dump\", s);

the working directory set ("dump") relative current working directory. might want check current working directory.

you should able set working directory executing assemblies directory code...

string exedir = path.getdirectoryname(assembly.getexecutingassembly().location); directory.setcurrentdirectory(exedir);

or, improve yet, don't utilize relative path, set p.startinfo.workingdirectory absolute path.

c# .net windows

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -