diff --git a/src/Files.App/Actions/Content/Archives/Decompress/BaseDecompressArchiveAction.cs b/src/Files.App/Actions/Content/Archives/Decompress/BaseDecompressArchiveAction.cs index 1c630e6d0d62..c043fa265886 100644 --- a/src/Files.App/Actions/Content/Archives/Decompress/BaseDecompressArchiveAction.cs +++ b/src/Files.App/Actions/Content/Archives/Decompress/BaseDecompressArchiveAction.cs @@ -91,15 +91,25 @@ protected async Task DecompressArchiveHereAsync(bool smart = false) if (zipFile is null) return true; - return zipFile.ArchiveFileData.Select(file => + static string? GetFirstMeaningfulSegment(string? fileName) { - var pathCharIndex = file.FileName.IndexOfAny(['/', '\\']); - if (pathCharIndex == -1) - return file.FileName; - else - return file.FileName.Substring(0, pathCharIndex); - }) - .Distinct().Count() > 1; + if (string.IsNullOrEmpty(fileName)) + return null; + + var parts = fileName.Split(['/', '\\'], StringSplitOptions.RemoveEmptyEntries); + foreach (var part in parts.Where(part => part is not "." and not "..")) + return part; + + return null; + } + + var topLevelEntries = zipFile.ArchiveFileData + .Select(file => GetFirstMeaningfulSegment(file.FileName)) + .Where(x => !string.IsNullOrEmpty(x)) + .Distinct() + .Count(); + + return topLevelEntries > 1; }); if (smart && currentFolder is not null && isMultipleItems)