update to check that EXE exists in path folder

This commit is contained in:
CWX 2022-07-25 22:31:30 +01:00
parent 87dd6edea4
commit f13f83451a
2 changed files with 21 additions and 3 deletions

View File

@ -23,7 +23,14 @@ namespace SPT_AKI_Installer.Aki.Core.Tasks
return GenericResult.FromError("EFT IS NOT INSTALLED!");
}
_data.OriginalGameVersion = PreCheckHelper.DetectOriginalGameVersion(_data.OriginalGamePath);
var result = PreCheckHelper.DetectOriginalGameVersion(_data.OriginalGamePath);
if (!result.Succeeded)
{
return result;
}
_data.OriginalGameVersion = result.Message;
if (_data.OriginalGamePath == null)
{
@ -40,6 +47,7 @@ namespace SPT_AKI_Installer.Aki.Core.Tasks
return GenericResult.FromError("Installer is located in a Folder that has existing Game Files. Please make sure the installer is in a fresh folder as per the guide");
}
return GenericResult.FromSuccess($"Current Game Version: {_data.OriginalGameVersion}");
}
}

View File

@ -1,4 +1,6 @@
using Microsoft.Win32;
using SPT_AKI_Installer.Aki.Core.Model;
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
@ -22,9 +24,17 @@ namespace SPT_AKI_Installer.Aki.Helper
return info?.DirectoryName;
}
public static string DetectOriginalGameVersion(string gamePath)
public static GenericResult DetectOriginalGameVersion(string gamePath)
{
return FileVersionInfo.GetVersionInfo(Path.Join(gamePath + "/EscapeFromTarkov.exe")).ProductVersion.Replace('-', '.').Split('.')[^2];
try
{
string version = FileVersionInfo.GetVersionInfo(Path.Join(gamePath + "/EscapeFromTarkov.exe")).ProductVersion.Replace('-', '.').Split('.')[^2];
return GenericResult.FromSuccess(version);
}
catch (Exception ex)
{
return GenericResult.FromError($"File not found: {ex.Message}");
}
}
}
}