backup problem
-
Hi...I didnt get a proper reply thats why i m posting it again....there is problem in backup of database.Here i m providing the code.. try { DateTime Time = DateTime.Now; int year = Time.Year; int month = Time.Month; int day = Time.Day; int hour = Time.Hour; int minute = Time.Minute; int second = Time.Second; int millisecond = Time.Millisecond; //Save file to C:\ with the current date as a filename string path ; string p = saveFileDialog1.FileName; path = p + year + "-" + month + "-" + day + "-" + hour + "-" + minute + "-" + second + "-" + millisecond + ".sql"; StreamWriter file = new StreamWriter(path); ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = @"C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqldump.exe"; psi.RedirectStandardInput = false; psi.RedirectStandardOutput = true; psi.Arguments = string.Format(@"-u{0} -p{1} -h{2} {3}", "root", "123456", "localhost", "userdb"); psi.UseShellExecute = false; Process process = Process.Start(psi); string output; output = process.StandardOutput.ReadToEnd(); file.WriteLine(output); process.WaitForExit(); file.Close(); process.Close(); MessageBox.Show("backup is created"); } catch (IOException ex) { if (System.Diagnostics.Debugger.IsAttached()) { Console.WriteLine(ex.ToString()); } else MessageBox.Show("Error , unable to backup!"); } } so the problem is when pointer reach to this line- Process process = Process.Start(psi) then an existing event is automatically called and i dont think that this event has to do anything with it....the event is this.. private void tabControl1_DrawItem(object sender, DrawItemEventArgs e) { // if (tabControl1.TabPages.Count != 1) { e.Graphics.DrawString("x", e.Font, Brushes.Black, e.Bounds.Right - 15, e.Bounds.Top + 4); e.Graphics.DrawString(this.tabControl1.TabPages[e.Index].Text, e.Font, Brushes.Black, e.Bounds.Left + 12, e.Bounds.Top + 4); e.DrawFocusRectangle(); } } so because of this i m unable to create a proper backup file...so plz give some suggestion....
-
Hi...I didnt get a proper reply thats why i m posting it again....there is problem in backup of database.Here i m providing the code.. try { DateTime Time = DateTime.Now; int year = Time.Year; int month = Time.Month; int day = Time.Day; int hour = Time.Hour; int minute = Time.Minute; int second = Time.Second; int millisecond = Time.Millisecond; //Save file to C:\ with the current date as a filename string path ; string p = saveFileDialog1.FileName; path = p + year + "-" + month + "-" + day + "-" + hour + "-" + minute + "-" + second + "-" + millisecond + ".sql"; StreamWriter file = new StreamWriter(path); ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = @"C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqldump.exe"; psi.RedirectStandardInput = false; psi.RedirectStandardOutput = true; psi.Arguments = string.Format(@"-u{0} -p{1} -h{2} {3}", "root", "123456", "localhost", "userdb"); psi.UseShellExecute = false; Process process = Process.Start(psi); string output; output = process.StandardOutput.ReadToEnd(); file.WriteLine(output); process.WaitForExit(); file.Close(); process.Close(); MessageBox.Show("backup is created"); } catch (IOException ex) { if (System.Diagnostics.Debugger.IsAttached()) { Console.WriteLine(ex.ToString()); } else MessageBox.Show("Error , unable to backup!"); } } so the problem is when pointer reach to this line- Process process = Process.Start(psi) then an existing event is automatically called and i dont think that this event has to do anything with it....the event is this.. private void tabControl1_DrawItem(object sender, DrawItemEventArgs e) { // if (tabControl1.TabPages.Count != 1) { e.Graphics.DrawString("x", e.Font, Brushes.Black, e.Bounds.Right - 15, e.Bounds.Top + 4); e.Graphics.DrawString(this.tabControl1.TabPages[e.Index].Text, e.Font, Brushes.Black, e.Bounds.Left + 12, e.Bounds.Top + 4); e.DrawFocusRectangle(); } } so because of this i m unable to create a proper backup file...so plz give some suggestion....
Your code calls
MessageBox.Show
, which obscures (part of) (one of) your app's windows; when you close the MessageBox, whatever was obscured needs repainting, that seems like why you are getting such event(s). Test the hypothesis by writing your messages to a file, or to a ListBox on your Window, rather than using MessageBox. In fact, I recommend to do that anyway, MessageBoxes are pretty annoying, while logging is very useful during development and afterwards. :) And please start using <PRE> tags (e.g.use the "code" widget) when showing code; it preserves formatting and improves readability.Luc Pattyn [My Articles] Nil Volentibus Arduum
-
Your code calls
MessageBox.Show
, which obscures (part of) (one of) your app's windows; when you close the MessageBox, whatever was obscured needs repainting, that seems like why you are getting such event(s). Test the hypothesis by writing your messages to a file, or to a ListBox on your Window, rather than using MessageBox. In fact, I recommend to do that anyway, MessageBoxes are pretty annoying, while logging is very useful during development and afterwards. :) And please start using <PRE> tags (e.g.use the "code" widget) when showing code; it preserves formatting and improves readability.Luc Pattyn [My Articles] Nil Volentibus Arduum