Add error handling for directory operation

This commit is contained in:
Jack251970 2025-06-06 13:25:43 +08:00
parent 57470a9799
commit f59e2399b9

View file

@ -294,16 +294,22 @@ public class FirefoxBookmarkLoader : FirefoxBookmarkLoaderBase
{ {
var platformPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); var platformPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
var packagesPath = Path.Combine(platformPath, "Packages"); var packagesPath = Path.Combine(platformPath, "Packages");
try
// Search for folder with Mozilla.Firefox prefix {
var firefoxPackageFolder = Directory.EnumerateDirectories(packagesPath, "Mozilla.Firefox*", // Search for folder with Mozilla.Firefox prefix
SearchOption.TopDirectoryOnly).FirstOrDefault(); var firefoxPackageFolder = Directory.EnumerateDirectories(packagesPath, "Mozilla.Firefox*",
SearchOption.TopDirectoryOnly).FirstOrDefault();
// Msix FireFox not installed // Msix FireFox not installed
if (firefoxPackageFolder == null) return string.Empty; if (firefoxPackageFolder == null) return string.Empty;
var profileFolderPath = Path.Combine(firefoxPackageFolder, @"LocalCache\Roaming\Mozilla\Firefox"); var profileFolderPath = Path.Combine(firefoxPackageFolder, @"LocalCache\Roaming\Mozilla\Firefox");
return GetProfileIniPath(profileFolderPath); return GetProfileIniPath(profileFolderPath);
}
catch
{
return string.Empty;
}
} }
} }