mysql - C# and mysqldump -


i'm writing application should make complete copy of 1 database , import on same server different name.
so, guess should use mysqldump , mysql , parameters should pass them.
okay, can't dump put file want, because have know location , pass mysql.

stringbuilder exportpath = new stringbuilder(); //exportpath.append(directory.getcurrentdirectory()); exportpath.append(@" > c:\temp\backup.sql");  process mysqldump = new process(); mysqldump.startinfo.useshellexecute = true; //mysqldump.startinfo.redirectstandardoutput = true; mysqldump.startinfo.filename = "mysqldump"; mysqldump.startinfo.arguments = "-u root -proot -h localhost mytable" + exportpath; mysqldump.start(); //string thedump = mysqldump.standardoutput.readtoend(); mysqldump.waitforexit(); mysqldump.close(); 

i'm doing wrong, don't know what.

you have 2 choices:

  • do not redirect output of mysqldump in command line, use more verbouse process creation , hook standard output of mysqldump. makes ist possible postprocess file (hash example) , either write out want, or run directly standard input of importing instance.
  • understand, > c:\\documents , settings\\admin\\desktop\\databases\\db.sql not command line parameter. need sssemble , parameter , redirection part string , use shell execution. make sure, use absolute path name.

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -