简体   繁体   中英

mysqldump.exe and mysql.exe access in C#

I'm writing an application which starts through command prompt mysql.exe and mysqldump.exe .
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 mysql.exe and mysqldump.exe 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM