Hi all,
I created a form in order to backup my postgres DB.
I'm using pg_dump.exe and executing it as process and setting CreateNoWindow = false and UseShellExecute = true in processStartInfo I can see opening DOS shell, I can see all single messages of pg_dump and Backup is successfully completed.
Now I'm trying to redirect all messages from dos shell into richTextBox without success.
With following code, backup is completed but I cannot see any message into richTextBox
As further check, if I consider as arguments tracert command, I can see in the richTextBox all messages in realt time
I specified also verbose option as reported in postGres documentation: "specifies verbose mode: This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error."
Any suggestion?
Thank in advanced
gio
I created a form in order to backup my postgres DB.
I'm using pg_dump.exe and executing it as process and setting CreateNoWindow = false and UseShellExecute = true in processStartInfo I can see opening DOS shell, I can see all single messages of pg_dump and Backup is successfully completed.
Now I'm trying to redirect all messages from dos shell into richTextBox without success.
With following code, backup is completed but I cannot see any message into richTextBox
redirect:
private void start_btn_Click(object sender, EventArgs e)
{
Task.Factory.StartNew(() =>
{
Process proc = new Process();
ProcessStartInfo info = new ProcessStartInfo();
//info.FileName = Application.StartupPath + @"\pg_dump.exe";
info.FileName = "cmd.exe";
info.CreateNoWindow = true;
info.UseShellExecute = false;
info.RedirectStandardInput = true;
info.RedirectStandardOutput = true;
info.RedirectStandardError = true;
//info.Arguments = @"cmd.exe /k tracert www.google.it";
//info.Arguments = @" --verbose --host=172.0.0.1 --port=5432 --username=radio --format=c --compress=6 --schema=dbo -d RNO --file C:\backupDB\RNO202111231008 ";
info.Arguments = @"cmd.exe /c C:\Backup_PostgreSQL\pg_dump.exe --verbose --host=172.0.0.1 --port=5432 --username=radio --format=c --compress=6 --schema=dbo -d RNO --file C:\backupDB\dump-RNO-20211123";
proc.StartInfo = info;
proc.OutputDataReceived += new DataReceivedEventHandler(OutputHandler);
proc.ErrorDataReceived += new DataReceivedEventHandler(ErrorHandler);
proc.SynchronizingObject = richTextBox1;
proc.Start();
proc.BeginOutputReadLine();
proc.WaitForExit();
proc.Close();
}
);
}
private void OutputHandler(Object source, DataReceivedEventArgs outLine)
{
// Collect the sort command output.
if (!String.IsNullOrEmpty(outLine.Data))
{
richTextBox1.AppendText(outLine.Data + "\r\n");
}
}
private void ErrorHandler(Object source, DataReceivedEventArgs outLine)
{
// Collect the sort command output.
if (!String.IsNullOrEmpty(outLine.Data))
{
richTextBox1.AppendText(outLine.Data + "\r\n");
}
}
As further check, if I consider as arguments tracert command, I can see in the richTextBox all messages in realt time
I specified also verbose option as reported in postGres documentation: "specifies verbose mode: This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error."
Any suggestion?
Thank in advanced
gio