Artemis.Modules.Games.EurotruckSimulator2.EurotruckSimulator2ViewModel.PlacePlugin C# (CSharp) Метод

PlacePlugin() публичный Метод

public PlacePlugin ( ) : void
Результат void
        public void PlacePlugin()
        {
            if (((EurotruckSimulator2Settings) GameSettings).GameDirectory == string.Empty)
                return;

            var path = ((EurotruckSimulator2Settings) GameSettings).GameDirectory;

            // Ensure the selected directory exists
            if (!Directory.Exists(path))
            {
                DialogService.ShowErrorMessageBox($"Directory '{path}' not found.");
                return;
            }
            // Ensure it's the ETS2 directory by looking for the executable
            if (!File.Exists(path + "/eurotrucks2.exe"))
            {
                DialogService.ShowErrorMessageBox("Please select a valid Eurotruck Simulator 2 directory\n\n" +
                                                  @"By default ETS2 is in \SteamApps\common\Euro Truck Simulator 2\bin\win_x64");
                return;
            }

            // Create the plugins folder if it's not already there
            Directory.CreateDirectory(path + "/plugins");

            // Place either the 64-bits or 32-bits DLL
            try
            {
                if (path.Contains("win_x64"))
                    File.WriteAllBytes(path + "/plugins/ets2-telemetry-server.dll", Resources.ets2_telemetry_server_x64);
                else
                    File.WriteAllBytes(path + "/plugins/ets2-telemetry-server.dll", Resources.ets2_telemetry_server_x86);

                MainManager.Logger.Debug("Installed ETS2 plugin in {0}", path);
            }
            catch (Exception e)
            {
                MainManager.Logger.Error(e, "Failed to install ETS2 plugin in {0}", path);
                throw;
            }
            
        }
    }