I have coded a Minecraft Server Runner in C# WinForms which lets you run a Minecraft Server, a .jar file which needs to generate files. The problem is that I launch this .jar file via the .exe application, and the files generate at the .exe application location.
— What I have tried:
I tried moving the .exe application to the specific server file location, but the application needs a restart to register this change which I don’t want to happen.
I also don’t want the user being forced to put the .exe application to the Server folder and restart it. Here is the code I use to launch the .jar file:
How can I fix this issue?
To fix this I executed the .jar file in the C# application via the CMD. Here is the code I used instead:
string path = @"C:userdocumentsserver"; //Path to your server.jar file. var process = new System.Diagnostics.Process(); process.StartInfo.FileName = path + "server.jar"; //Name of the .jar file. process.StartInfo.WorkingDirectory = path; process.StartInfo.UseShellExecute = true; process.Start();
All credits go to “Olivier Rogier” ( https://stackoverflow.com/users/12031933/olivier-rogier ) for helping me find this solution