From 6758465fc111539f013ebf96d8343bfdc8bb4823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nha=CC=82n=20Cha=CC=82u=20KP?= Date: Thu, 27 Feb 2025 17:04:46 +0700 Subject: [PATCH] Add an option to specify the saved file name to fix incorrect file name formatting. --- AutoUpdater.NET/DownloadUpdateDialog.cs | 4 +++- AutoUpdater.NET/UpdateInfoEventArgs.cs | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/AutoUpdater.NET/DownloadUpdateDialog.cs b/AutoUpdater.NET/DownloadUpdateDialog.cs index 55c25133..7879be11 100644 --- a/AutoUpdater.NET/DownloadUpdateDialog.cs +++ b/AutoUpdater.NET/DownloadUpdateDialog.cs @@ -125,7 +125,9 @@ private void WebClientOnDownloadFileCompleted(object sender, AsyncCompletedEvent } } - string fileName = string.IsNullOrEmpty(contentDisposition?.FileName) + string fileName = !string.IsNullOrEmpty(_args.DownloadFileName) + ? _args.DownloadFileName: + string.IsNullOrEmpty(contentDisposition?.FileName) ? Path.GetFileName(_webClient.ResponseUri.LocalPath) : contentDisposition.FileName; diff --git a/AutoUpdater.NET/UpdateInfoEventArgs.cs b/AutoUpdater.NET/UpdateInfoEventArgs.cs index ba326437..aea4d5c8 100644 --- a/AutoUpdater.NET/UpdateInfoEventArgs.cs +++ b/AutoUpdater.NET/UpdateInfoEventArgs.cs @@ -18,6 +18,12 @@ public UpdateInfoEventArgs() Mandatory = new Mandatory(); } + /// + /// It will be prioritized if provided. Used in cases where the download URL does not contain a file name (e.g., Base64) or the header does not include Content-Disposition + /// + [XmlElement("filename")] + public string DownloadFileName { get; set; } + /// /// If new update is available then returns true otherwise false. ///