Reputation: 33
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?
Upvotes: 0
Views: 1212
Reputation: 100527
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;
Upvotes: 0
Reputation: 158309
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 + "\"";
Upvotes: 2