C# double quote argument -
in app.config file, have:
add key="datafilelocation" value="e:\program files\microsoft sql server\mssql12.mssqlserver\mssql\data\"/> in code have:
process p2 = new process(); p2.startinfo.filename = "restore.bat"; p2.startinfo.arguments = + "\"" + datafilelocation.tostring() + "\""; p2.startinfo.useshellexecute = false; p2.startinfo.redirectstandardoutput = true; p2.startinfo.createnowindow = true; p2.start(); the output 'restore.bat' is:
-v dataloc=\"e:\\program files\\microsoft sql server\\mssql12.mssqlserver\\mssql\\data\\\" as can see, there's "\" @ beginning breaking bat/sql statement...
andrew
in case seems adding \, output according logic.
the best way combine path should use path.combine method provided static path class, takes care of \
try this
var finalpath = path.combine(datafilelocation.tostring(), "what_ever_path_you_want_to_combine");
Comments
Post a Comment