Skip to content

Commit

Permalink
fix: new FileInfo may throw exception
Browse files Browse the repository at this point in the history
  • Loading branch information
emako committed Jan 7, 2025
1 parent b4fa653 commit 309aa7e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
**应募一个MicaSetup程序图标 | Request a contribution of a MicaSetup program icon | プログラムのアイコンはただ今応募受付中**

![logo64](./branding/logo64.png)

[![Actions](https://github.com/lemutec/MicaSetup/actions/workflows/micasetup.yml/badge.svg)](https://github.com/lemutec/MicaSetup/actions/workflows/micasetup.yml) [![Platform](https://img.shields.io/badge/platform-Windows-blue?logo=windowsxp&color=1E9BFA)](https://dotnet.microsoft.com/zh-cn/download/dotnet/latest/runtime)
Expand Down
2 changes: 1 addition & 1 deletion build/MicaSetup.Tools/MakeIcon.Shared/ImageHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static void SaveImage(IconType type, FontFamily fontFamily, string filena
IconType.Uninst => nameof(IconType.Uninst),
_ => string.Empty,
}}";
string output = Path.Combine(new FileInfo(filename).DirectoryName, $"{pathNoExt}{ext}");
string output = Path.Combine(Path.GetDirectoryName(filename), $"{pathNoExt}{ext}");

try
{
Expand Down
2 changes: 1 addition & 1 deletion build/MicaSetup/Helper/Setup/PrepareUninstallPathHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static UninstallDataInfo GetPrepareUninstallPath()
domainFilePath = CommandLineHelper.Values[TempPathForkHelper.ForkedCli];
}

string installLocation = new FileInfo(domainFilePath).DirectoryName;
string installLocation = Path.GetDirectoryName(domainFilePath);
string uninstallDataPath = Path.Combine(installLocation, "Uninst.dat");
string uninstallData = "Uninst.dat";

Expand Down
4 changes: 2 additions & 2 deletions build/MicaSetup/Helper/System/SpecialPathHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public static string GetPath(string baseName)
{
string configPath = Path.Combine(GetFolder(), baseName);

if (!Directory.Exists(new FileInfo(configPath).DirectoryName))
if (!Directory.Exists(Path.GetDirectoryName(configPath)))
{
_ = Directory.CreateDirectory(new FileInfo(configPath).DirectoryName!);
_ = Directory.CreateDirectory(Path.GetDirectoryName(configPath));
}
return configPath;
}
Expand Down
6 changes: 3 additions & 3 deletions build/MicaSetup/Helper/System/StartMenuHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static void CreateStartMenuFolder(string folderName, string targetPath, b

if (isCreateUninst)
{
string uninstTargetPath = Path.Combine($"{new FileInfo(targetPath).Directory.FullName}", "Uninst.exe");
string uninstTargetPath = Path.Combine($"{Path.GetDirectoryName(targetPath)}", "Uninst.exe");
ShortcutHelper.CreateShortcut(startMenuFolderPath, $"Uninstall_{folderName}", uninstTargetPath);
}
}
Expand Down Expand Up @@ -63,8 +63,8 @@ public static bool PinToStartMenu(string filePath)
{
Type shellType = Type.GetTypeFromProgID("Shell.Application");
object shellObject = Activator.CreateInstance(shellType);
dynamic folder = shellType.InvokeMember("Namespace", BindingFlags.InvokeMethod, null, shellObject, [new FileInfo(filePath).DirectoryName]);
dynamic item = folder.ParseName(new FileInfo(filePath).Name);
dynamic folder = shellType.InvokeMember("Namespace", BindingFlags.InvokeMethod, null, shellObject, [Path.GetDirectoryName(filePath)]);
dynamic item = folder.ParseName(Path.GetFileName(filePath));
dynamic verbs = item.Verbs();

foreach (dynamic verb in verbs)
Expand Down

0 comments on commit 309aa7e

Please sign in to comment.