From be37b2ecb29aebdf611ed805b689c713e50f2b14 Mon Sep 17 00:00:00 2001 From: "Jacob P." Date: Wed, 17 Jun 2026 01:44:14 +0200 Subject: [PATCH] Fix output path detection to correctly identify directories and files --- DiscordChatExporter.Core/Exporting/ExportRequest.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/DiscordChatExporter.Core/Exporting/ExportRequest.cs b/DiscordChatExporter.Core/Exporting/ExportRequest.cs index db83d98a..1285b246 100644 --- a/DiscordChatExporter.Core/Exporting/ExportRequest.cs +++ b/DiscordChatExporter.Core/Exporting/ExportRequest.cs @@ -206,10 +206,15 @@ public partial class ExportRequest { var actualOutputPath = FormatPath(outputPath, guild, channel, after, before); - // Output is a directory + // Determine whether the output path refers to a directory or a file. + // The extension-based heuristic is evaluated on the original, unsubstituted path, + // because the value of a template token (e.g. a guild or channel name) may contain + // a period that would otherwise be mistaken for a file extension, incorrectly causing + // a directory path to be treated as a file. + // https://github.com/Tyrrrz/DiscordChatExporter/issues/1502 if ( Directory.Exists(actualOutputPath) - || string.IsNullOrWhiteSpace(Path.GetExtension(actualOutputPath)) + || string.IsNullOrWhiteSpace(Path.GetExtension(outputPath)) ) { var fileName = GetDefaultOutputFileName(guild, channel, format, after, before);