0

I use the following command which should create a separate EXE file (Player.exe as an interpreter).:

copy / b player.exe + game.zip game.ehe 

But, the command did not create (even if the bat file is obtained), and launches an empty player.exe without game.zip.

My below code does not work:

private void button2_Click(object sender, EventArgs e)
{
    saveDialog.Filter = "exe | *.exe";
    if (saveDialog.ShowDialog() == DialogResult.OK) ;
    {
        ProcessStartInfo info = new ProcessStartInfo();
        info.FileName = @"engine\windows\player.exe";
        info.Arguments = "/b copy " + labelPath + saveDialog.FileName;
        info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
        using (Process process = Process.Start(info))
        {
            process.WaitForExit();
        }
    }
}

Can somebody tell me why my code is not working as expected?

2 Answers 2

2

Are there spaces in the file path that you pass? If so, you will probably want to quote the string:

info.Arguments = "/b copy \"" + labelPath + saveDialog.FileName + "\"";
Sign up to request clarification or add additional context in comments.

Comments

0

Another option if labelPath is of type Label than + will call ToString on it and resulting string will be something like "...Label...". You may need something like (may need to combine with Fredrik Mörk's answer if path have spaces):

info.Arguments = "/b copy labelPath.Text + saveDialog.FileName; 

1 Comment

@user1667616, "does not work" is not an explanation of a problem. Step through the code in debugger and look at everything, make sure you are happy with values, make sure you are not eating exceptions, and post detail of such investigation in your question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.