parsing parameter from a .net WIN-GUI application to a win32 console app.

the application uses 2 parameters like: myConsole <input-file> <output-file>, and is well tested and functional from the command-prompt!
When using the .net windows-application, a process is created by the usage of Process.StartInfo properties, like FileName and StartInfo.Arguments... but the application does not respond... what am I doing wrong?
faroeseTelecomAsked:
Who is Participating?
 
vinhnlConnect With a Mentor Commented:
You can add char \" into sourceFileRef, destFileRef  :

sourceFileRef  = "\"" + sourceFileRef + "\"";
destFileRef = "\"" + destFileRef + "\"";

Good luck
VINHNL
0
 
existenz2Commented:
Can you post the code you are using for it? We can help you better that way.
0
 
faroeseTelecomAuthor Commented:
Process myProcess = new Process();    //create a process - from System.Diagnostics.Process
myProcess.StartInfo.FileName = this.exeRef;     //reference to the executeble
myProcess.StartInfo.CreateNoWindow = false;  // hide the command window
myProcess.StartInfo.Arguments = this.sourceFileRef + " " + this.destFileRef;  //params: <input file> <output file>
myProcess.Start();   // starting process with exec. and params.
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
vinhnlCommented:
You can modify method Main():

            [STAThread]
            static void Main(string[] args)
            {
                  if( args.Length >1)
                        MessageBox.Show(args[0] + " " + args[1]);
                  Application.Run(new Form1());
            }
0
 
vinhnlCommented:
Hi faroeseTelecom,

I tested your code. It is OK!
0
 
faroeseTelecomAuthor Commented:
the main method is not accessible - a  standard win32 (with MFC and not .net) console main method
int main(int argc, char* argv[]), that should result i a streight forward process call...

I have now tried by the process static method call:

ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = programReference.Text;
startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = false;
startInfo.Arguments = sourceFileRef + " " + destFileRef;
System.Diagnostics.Process.Start(startInfo);

...but the result is the same...
0
 
faroeseTelecomAuthor Commented:
can it be that the file references must have double-backslashes for file references on win32? ....worth the try...
0
 
vinhnlCommented:
Is programReference.Text a full path? ("C:\\MyConsol.exe")
0
 
faroeseTelecomAuthor Commented:
yes all references are absolute.
0
 
faroeseTelecomAuthor Commented:
found the error - the path contains spaces to the source- and dest file, therefore was badly interpred by the executable.
0
 
vinhnlCommented:
Yes, I think  sourceFileRef or destFileRef has  space char
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.