fix.在线安装器,启动器

This commit is contained in:
lincube
2026-06-05 11:08:11 +08:00
parent bb4e90ea8d
commit 8c88e305ee
42 changed files with 1507 additions and 393 deletions

View File

@@ -2,6 +2,8 @@ namespace LanDesktopPLONDS.Installer.Services;
public static class InstallerPathGuard
{
public const string ApplicationDirectoryName = "LanMountainDesktop";
public static string GetDefaultInstallPath()
{
var programFiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
@@ -12,7 +14,29 @@ public static class InstallerPathGuard
"Programs");
}
return Path.Combine(programFiles, "LanMountainDesktop");
return Path.Combine(programFiles, ApplicationDirectoryName);
}
public static string GetInstallPathForSelectedFolder(string selectedFolder)
{
if (string.IsNullOrWhiteSpace(selectedFolder))
{
throw new ArgumentException("Selected folder is required.", nameof(selectedFolder));
}
var fullPath = Path.GetFullPath(selectedFolder.Trim());
var root = Path.GetPathRoot(fullPath);
var trimmedPath = fullPath.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
var trimmedRoot = root?.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
var basePath = string.Equals(trimmedPath, trimmedRoot, StringComparison.OrdinalIgnoreCase)
? fullPath
: trimmedPath;
var selectedName = Path.GetFileName(trimmedPath);
var installPath = string.Equals(selectedName, ApplicationDirectoryName, StringComparison.OrdinalIgnoreCase)
? trimmedPath
: Path.Combine(basePath, ApplicationDirectoryName);
return NormalizeInstallPath(installPath);
}
public static string NormalizeInstallPath(string path)