I decided to make a bootloader for the program, which checks the version, if it is necessary, downloads and closes itself and opens the program itself . I have code in the bootloader

if (version != Launcher.version) { DownloadNewVersion(); } else { Application.Exit(); Process process = new Process(); process.StartInfo.FileName = @"data\NiceSufring.exe"; process.Start(); } 

The program must run the program at data\NiceSufring.exe , and it starts, when the program starts, it reads from the data\system\system.fat , but the trouble is that if you run the program through the bootloader, the compiler gives an error

Could not find a part of the path

And if you run the program without a bootloader, but just the .exe itself, then there is no such error and everything is working fine, tell me why this could be? I have been fighting for 2 days, I just can’t understand what's the matter.

  • I don’t know the answer to your question, but I have a question for your code, why is the if (version! = Launcher.version) condition so, and not ">"? - andreich
  • 2
    NiceSu fr ing.exe painfully reminds svcho ts .exe - karmadro4
  • I know that there is a mistake, then I'll fix it. - Angus123

1 answer 1

Show a piece of code that works with data\system\system.fat in NiceSufring.exe , namely how you get the path to system.fat .

If I understand your files and folders structure correctly, then most likely you have the following error:

In the file NiceSufring.exe path to system.fat registered as system\system.fat . This is a relative path, the name of the current working directory is added to it and therefore, when you start up directly, everything opens normally. But when launched via Process working directory inherits from the launching process, and since there is no system\system.fat in the root directory of the program, the program crashes. Therefore, you need to explicitly set the correct working directory for NiceSufring.exe .

 Process process = new Process(); process.StartInfo.WorkingDirectory = "data"; process.StartInfo.FileName = "NiceSufring.exe"; process.Start(); 

Or alter NiceSufring.exe so that the program, when opened, looked for system\system.fat not in the working directory, but in the directory with its executable file.

 string correctcwd = new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName; string filename = correctcwd + @"\system\system.fat"; 
  • Thanks for it ... it worked! :) - Angus123