Skip to content

Fail to preview files with long path #1643

Closed

Description

@1821746019

Describe the bug

Quicklook

Image

msedge

Image

Copy file path in context menu(ctrl+shift+c)

Image

To Reproduce
Steps to reproduce the behavior:

  1. run these command in cmd
cd /d D:\
set dir_name="这是一个名字很长的的文件夹,但其还不会超出MAX_PATH(256)_this is a folder with long name, but its path would not exceed MAX_PATH____________________________________________________________"
set file_name="这是一个名字很长的文件,若和上面的folder同级仍可正常预览,但移动到folder内后就不行了_this is a file with long name. When placed in the same level with folder above, it can be previewed normally. But when placed in the folder above, it cannot.html"

mkdir %dir_name%
echo "content of html" > %file_name%
move %file_name% %dir_name%
  1. preview the file

Expected behavior
preview work with long path

Desktop (please complete the following information):
win10 22H2

Activity

  1. added a commit that references this issue on May 23, 2025
  2. emako commented on May 23, 2025

    @emako
    Member

    Image

    You can check it after version 4.0.1-20 (QuickLook-4.0.1-20-geff9d79.msi)

    https://github.com/QL-Win/QuickLook/releases/tag/latest

  3. emako commented on May 23, 2025

    @emako
    Member

    If there are any questions, please continue to comment.

  4. 1821746019 commented on May 24, 2025

    @1821746019
    Author

    I install the v4.0.2-1-gd20eb71. It failed still. I think it will be nice to translate the long path to the short one before passing the path, like what ctrl+shift+c do.

    Image

  5. reopened this on May 24, 2025
  6. emako commented on May 24, 2025

    @emako
    Member

    I'll keep track of the problem.

  7. 1821746019 commented on Jun 4, 2025

    @1821746019
    Author

    Is there any good news?

  8. 1821746019 commented on Oct 1, 2025

    @1821746019
    Author

    @emako 大佬, 什么时候把这个bug修修

  9. emako commented on Oct 1, 2025

    @emako
    Member

    Since this involves the underlying codebase architecture, it can be considered a relatively low priority.

  10. 1821746019 commented on Oct 2, 2025

    @1821746019
    Author

    😥

  11. added this to the 4.0.0 milestone on Oct 5, 2025
  12. emako commented on Oct 6, 2025

    @emako
    Member

    测试下来edge(以及WebView2)本身就没法支持路径大于260字符,因此File not found是符合预期的

    After testing, edge (and WebView2) cannot support paths greater than 260 characters, so File not found is as expected.

  13. 1821746019 commented on Oct 7, 2025

    @1821746019
    Author

    You've correctly identified the issue. WebView2, like Edge, is limited by the legacy MAX_PATH (260 characters) constraint and fails to load files when this limit is exceeded.

    Windows Explorer works around this by converting long paths to their 8.3 short-path equivalent before passing them to other applications. We need to replicate this exact behavior.

    The solution is to preprocess file paths before they are passed to WebView2. If a path exceeds the MAX_PATH limit, we must first convert it to its short name alias.

    Recommended API
    To achieve this, use the GetShortPathNameW Win32 API. This function directly converts a long file path into its 8.3 equivalent.

    C/C++ Signature:

    DWORD GetShortPathNameW(
      [in]  LPCWSTR lpszLongPath,
      [out] LPWSTR  lpszShortPath,
      [in]  DWORD   cchBuffer
    );

    By implementing this, WebView2 will receive a compliant path (e.g., D:\THISIS1\FILE1.HTM) and render the file correctly, mimicking Explorer's functionality.

    For example:

    Original Long Path:
    D:\这是一个名字很长的的文件夹...\这是一个名字很长的文件....html

    Should be converted to:
    D:\THISIS~1\THISIS~1.HTM (Note: The short name is system-generated)

  14. reopened this on Oct 7, 2025
  15. emako commented on Oct 7, 2025

    @emako
    Member

    I thought about it and found a solution.

  16. emako commented on Oct 7, 2025

    @emako
    Member

    Done in 78843d8 and you can try it in preview version
    https://github.com/QL-Win/QuickLook/releases/tag/latest

  17. 1821746019 commented on Oct 8, 2025

    @1821746019
    Author

    Nice job. It works now.👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions