Restore Mysql database from C# code

Hi Experts,
I'm trying to restore mysql database using C# code
Can someone tell me what wrong in my code or suggest me an apropriate issue
I tried the following and does not work
public static void UnDumpDatabase(string server, string database, string user, string password, string FilePath)
                ProcessStartInfo proc = new ProcessStartInfo();
                string args = string.Format(@"-h{0} -u{1} -p{2} {3} < {4}", server, user, password, database, FilePath);
                proc.FileName = ProgramFilesx86() + "\\MySQL\\MySQL Server 5.0\\bin\\mysql.exe";
                proc.Arguments = args;
                proc.CreateNoWindow = true;
                proc.UseShellExecute = false;
                proc.WindowStyle = ProcessWindowStyle.Hidden;
                Process p = Process.Start(proc);
            catch (Exception)


Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Roshan DavisCommented:
can you replace the Process.Start with the following statements?
using (Process p = Process.Start(proc))

Open in new window

humer2000Author Commented:
It does'nt work ! no database changes and p.exitcode = 1
Roshan DavisCommented:
1. Are you able to do this through command line?
2. Can you make sure the path for the mysql.exe is correct?
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

humer2000Author Commented:
It works when i did it through cmd when concatening p.filename and p.arguments
Roshan DavisCommented:
looks like the spaces in the filename may not liking it.
can you put a double quote before and after of proc.FileName?
humer2000Author Commented:
When I tried to run the code in Console application as the same way i do, it will end up with getting the information of mysql help command (the one we got if we type "mysql --help" in command prompt). Nothing happen at database side, no data is restored and no error is thrown.
What kind of errors did you see?
humer2000Author Commented:
No error is thrown.
I aborted trying to find solution after hours and days of frustration, and I bought a solution doing the job finely.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.