Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6669197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:07:19+00:00 2026-05-26T03:07:19+00:00

I am trying to backup the database using mysql and c# by using following

  • 0

I am trying to backup the database using mysql and c#
by using following way…

  public static  void backupDatabase()
    {
        Process sd = null;
        ProcessStartInfo r1 = new ProcessStartInfo("C:\\Program Files\\MySQL\\MySQL Workbench 5.2 CE\\", "--databases=access --compress --routines --triggers --add-drop-database --add-drop-table --add-locks --extended-insert --port=3080 --user=root --disable-keys --quick --comments --complete-insert --result-file=DUMPEDOUTPUT.sql");

        r1.CreateNoWindow = true;
        r1.WorkingDirectory = "C:\\Program Files\\MySQL\\MySQL Workbench 5.2 CE\\";
        r1.UseShellExecute = false;
        r1.WindowStyle = ProcessWindowStyle.Minimized;
        r1.RedirectStandardInput = false;

        sd = Process.Start(r1);
         sd.WaitForExit();

        if (!sd.HasExited)
        {
             sd.Close();
        }
        sd.Dispose();
         r1 = null;
         sd = null;  

    }

got an exception at this line sd = Process.Start(r1);

Exception :{"The directory name is invalid"}   Win32Exception Was unhandled

would any one pls help me guys

Many thanks In advance..

Modified Code :

  public static  void backupDatabase()
    {
        Process sd = null;
        ProcessStartInfo r1 = new ProcessStartInfo("MySQLWorkbench.exe", "--databases access --compress --routines --triggers --add-drop-database --add-drop-table --add-locks --extended-insert --port=3080 --user=root --disable-keys --quick --comments --complete-insert --result-file=DUMPEDOUTPUT.sql");

        r1.CreateNoWindow = true;
        r1.WorkingDirectory = @"C:\Program Files\MySQL\MySQL Workbench 5.2 CE\MySQLWorkbench.exe";
        r1.UseShellExecute = false;
        r1.WindowStyle = ProcessWindowStyle.Minimized;
        r1.RedirectStandardInput = false;

        sd = Process.Start(r1);
         sd.WaitForExit();

        if (!sd.HasExited)
        {
             sd.Close();
        }
        sd.Dispose();
         r1 = null;
         sd = null;  

    }

I am getting same error at the same line ..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:07:19+00:00Added an answer on May 26, 2026 at 3:07 am

    The first parameter to the ProcessStartInfo should be the executable you want to run. Right now you have it pointing to a directory

    new ProcessStartInfo("C:\\Program Files\\MySQL\\MySQL Workbench 5.2 CE\\", ...
    

    It should probably be

    new ProcessStartInfo(
       @"C:\Program Files\MySQL\MySQL Workbench 5.2 CE\MySQLWorkbench.exe", ...
    

    You can also specifiy the path name by using @ in front of the string so you dont need to escape the backslashes. Like this:

    new ProcessStartInfo(@"C:\Program Files\MySQL\MySQL Workbench 5.2 CE\", ...
    

    Update 1

    Another thing to try, since you already specify the working directory, just put the executable name in the ProcessStartInfo

    new ProcessStartInfo("MySQLWorkbench.exe", ...
    

    Update 2

    Just noticed you added the exe filename to the WorkingDirectory. This should just be the directory:

    Process sd = null;
    ProcessStartInfo r1 = new ProcessStartInfo("MySQLWorkbench.exe", ...);
    
    r1.CreateNoWindow = true;
    r1.WorkingDirectory = @"C:\Program Files\MySQL\MySQL Workbench 5.2 CE";
    

    But I think the issue is probably the permissions. My guess is the current user doesnt have permissions to this file path.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to restore the database file(backup.sql) using c# by the following method...
I have taken the backup of mysql database but when I am trying to
I'm trying to write a PHP script to backup a MySQL database: if (
I was trying to create a backup for my SQL Server Database using SQL
I am trying to pragmatically run a backup of an SQL Server database using
I am trying to backup a database using the PHP system command and mysqldump.exe.
Hello I'm trying to take backup from mysql command line client. I'm using mysqldump
Can anyone help me, I'm trying to backup a database located on localhost\SQLEXPRESS but
I’m trying to backup a SQL08 database to a target on a remote drive
I am trying to backup my Firebird 2.5 database file by code: FbBackup backupSvc

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.