I'm Having trouble with running a CMD command within this program. I'm using the "lua LuaSrcDiet.lua myscript.lua -o myscriptdone.lua" command. Whenever I run the program, it tells me it can't find the file specified. I guessing this is due to Command Prompt not being in the correct directory when ran. The correct directory is the user folder. Is there any way you can think of so I can fix this. Thanks so much.
try
{
File.Copy(filedir1, userPath + "/myscript.lua", true);
}
catch
{
MessageBox.Show("There has been an problem. It may be because you need to select a Lua file to open.", "Love Compiler", MessageBoxButton.OK, MessageBoxImage.Error);
}
File.Copy("Stuff/LuaDiet/lua.exe", userPath + "/lua.exe", true);
File.Copy("Stuff/LuaDiet/LuaSrcDiet.lua", userPath + "/LuaSrcDiet.lua", true);
Process luarun = new Process();
luarun.StartInfo.WorkingDirectory = @"C:\Users\Leachman";
luarun.StartInfo.FileName = "lua LuaSrcDiet.lua myscript.lua -o myscriptdone.lua";
luarun.StartInfo.UseShellExecute = false;
luarun.StartInfo.Arguments = "/all";
luarun.StartInfo.RedirectStandardOutput = true;
luarun.StartInfo.CreateNoWindow = false;
luarun.Start();
Just Edit These Lines :
FROM :
TO :
I think this should work!
UPDATE
After seeing your comments, I realized that you should use
AsynchronousFileCopy
.CODE from
Answer of another SO Question
:Call It Like :
Looks like you're trying to pass arguments in the filename field. Try setting the filename to the actual filename (lua.exe) and moving the other items to the arguments section.