Quote and prefix long paths when copying to clipboard

Paths copied to the clipboard are now quoted, and long paths (>= 260 characters) are prefixed with \\?\ to ensure compatibility. This improves reliability when handling long file paths.
This commit is contained in:
ema
2025-10-06 15:50:25 +08:00
parent 1aaf3cb0b2
commit 0d0c71407c
2 changed files with 2 additions and 2 deletions

View File

@@ -48,7 +48,7 @@ internal static class Helper
uri.Append('/');
else
uri.Append($"%{(int)v:X2}");
if (uri.Length >= 2 && uri[0] == '/' && uri[1] == '/') // UNC path
if (uri.Length >= 2 && uri[0] == '/' && uri[1] == '/') // UNC path - Universal Naming Convention
uri.Insert(0, "file:");
else
uri.Insert(0, "file:///");

View File

@@ -115,7 +115,7 @@ public partial class ViewerWindow : Window
{
try
{
Clipboard.SetText(_path);
Clipboard.SetText($"\"{(_path.Length >= 260 ? @"\\?\" + _path : _path)}\"");
Toast.Success(TranslationHelper.Get("InfoPanelMoreItem_CopySucc"));
}
catch (Exception e)