mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-02 21:20:28 +12:00
fixed #834: Indexer catch unauthorized access exception
This commit is contained in:
parent
6d6e338bf1
commit
e2746e47e3
|
@ -196,7 +196,7 @@ public static bool IsBlurPossible(int radius)
|
||||||
Version version = Environment.OSVersion.Version;
|
Version version = Environment.OSVersion.Version;
|
||||||
bool isWindows8OrHigher = (version.Major == 6 && version.Minor >= 2) || version.Major > 6;
|
bool isWindows8OrHigher = (version.Major == 6 && version.Minor >= 2) || version.Major > 6;
|
||||||
|
|
||||||
return !isWindows8OrHigher || radius >= 20; ;
|
return !isWindows8OrHigher || radius >= 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -77,31 +77,37 @@ protected FolderInfo GetFolderInfo(string folderPath, int level = 0)
|
||||||
|
|
||||||
if (config.MaxDepthLevel == 0 || level < config.MaxDepthLevel)
|
if (config.MaxDepthLevel == 0 || level < config.MaxDepthLevel)
|
||||||
{
|
{
|
||||||
DirectoryInfo currentDirectoryInfo = new DirectoryInfo(folderPath);
|
try
|
||||||
|
|
||||||
foreach (DirectoryInfo directoryInfo in currentDirectoryInfo.GetDirectories())
|
|
||||||
{
|
{
|
||||||
if (config.SkipHiddenFolders && directoryInfo.Attributes.HasFlag(FileAttributes.Hidden))
|
DirectoryInfo currentDirectoryInfo = new DirectoryInfo(folderPath);
|
||||||
|
|
||||||
|
foreach (DirectoryInfo directoryInfo in currentDirectoryInfo.GetDirectories())
|
||||||
{
|
{
|
||||||
continue;
|
if (config.SkipHiddenFolders && directoryInfo.Attributes.HasFlag(FileAttributes.Hidden))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
FolderInfo subFolderInfo = GetFolderInfo(directoryInfo.FullName, level + 1);
|
||||||
|
folderInfo.Folders.Add(subFolderInfo);
|
||||||
|
subFolderInfo.Parent = folderInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
FolderInfo subFolderInfo = GetFolderInfo(directoryInfo.FullName, level + 1);
|
foreach (FileInfo fileInfo in currentDirectoryInfo.GetFiles())
|
||||||
folderInfo.Folders.Add(subFolderInfo);
|
|
||||||
subFolderInfo.Parent = folderInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (FileInfo fileInfo in currentDirectoryInfo.GetFiles())
|
|
||||||
{
|
|
||||||
if (config.SkipHiddenFiles && fileInfo.Attributes.HasFlag(FileAttributes.Hidden))
|
|
||||||
{
|
{
|
||||||
continue;
|
if (config.SkipHiddenFiles && fileInfo.Attributes.HasFlag(FileAttributes.Hidden))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
folderInfo.Files.Add(fileInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
folderInfo.Files.Add(fileInfo);
|
folderInfo.Files.Sort((x, y) => x.Name.CompareTo(y.Name));
|
||||||
|
}
|
||||||
|
catch (UnauthorizedAccessException)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
folderInfo.Files.Sort((x, y) => x.Name.CompareTo(y.Name));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return folderInfo;
|
return folderInfo;
|
||||||
|
|
Loading…
Reference in a new issue