Process question

D

DBC User

In my c# program I need to call an old legacy program for doing data
conversion. For that I have written a code like this follows

Process proc = new Process();
proc.StartInfo.CreateNoWindow = false;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
proc.StartInfo.ErrorDialog = true;
proc.StartInfo.FileName = "EditCD.exe";
proc.StartInfo.WorkingDirectory = _drive +
@":\myleg\appdir\";
proc.Start();
log.Info("Processed started & waiting for output");
proc.WaitForExit();
log.Info("Wait completed " + returnFileName);
if (!File.Exists(returnFileName))
returnFileName = null;
log.Info("Done Processing -> " + returnFileName);

When I run, I get to log info "process started & waiting for output"
but it doesn't go any further than that. The legacy program doesn't
have any window to show either. I checked the taxk panel and the legacy
program is not running. What am I doing wrong?
 
D

Dave Sexton

Hi,

"You can change the value of any ProcessStartInfo property up to the time that
the process starts. After you start the process, changing these values has no
effect."

ProcessStartInfo class on MSDN:
http://msdn2.microsoft.com/en-us/library/system.diagnostics.processstartinfo.aspx

Try using the following code instead:

using (Process proc = new Process())
{
ProcessStartInfo info = new ProcessStartInfo();
info.ErrorDialog = true;
info.FileName = "EditCD.exe";
info.WorkingDirectory = _drive +
@":\myleg\appdir\";

proc.Start(info);
...
}
 
D

Dave Sexton

I just realized that I misinterpreted that quote from MSDN and I no longer
think it applies to your situation. Sorry about that.

Try my snippet anyway to see if it fixes your problem.
 
W

Wired

Some of the processes will require you to empty their standard buffers
before they will exit. This is something I faced with Oracle's sqlldr.
Redirect the Process's standard output and error, and Read the buffers to
end. Hope that helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top