David White David White - 2 years ago 220
SQL Question

mysqldump.exe and mysql.exe access in C#

I'm writing an application which starts through command prompt


The idea is to make a backup and then upload it to mysql with different database name.

The problem is that I didn't think what would happen if these
are not registered in the cmd and you have to type the path to them manually.

And my application breaks.

So I'm wondering is there any automatic way to find the path to these two files to run them correctly.

The other solution that comes to my mind is to let the user browse his files and select these executables.

Answer Source

To manage this path you can use an environment variable and get it from your application.

string sPath = System.Environment.GetEnvironmentVariable("MYSQL_DIR");

Other solution is copy both executables to your application path and access them with a relative path.

string sPath = "./";

Hope it helps.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download