Case #
You have a SharePoint Online site or Onedrive for business file which is synced to your local Windows machine. You try to open the file and you get the following error: "There was an error while opening this document. the path does not exist". This article provides guidance on how to fix the path does not exist error in Windows.
Solution #
This error may stem from the below possible root causes.
- The file may be blocked after download, read-only or corrupt. First you should ensure that the file is not blocked, by right clicking, clicking Properties and then checking the General tab. You should also right click the file and ensure that is is not read-only. You can check the same in the command line via the "attrib" command.

- The file path may exceed the Sharepoint Online or Windows operating system native limit of the maximum file path length. This limit is 400 characters for Sharepoint Online decoded paths and 256 characters for the Windows operating system. Also the following limitations apply.
- The length of the OneDrive root folder (e.g. C:\users\username\OneDrive - Contoso) + the relative path of the file (up to 400 chars) cannot be more than 520 characters.
- Each segment of the path (a segment is a file name or folder name like “Promotion” or “Some File.xlsx” in the examples above) can't be more than 255 characters due to operating system limitations.
- SharePoint Server versions only support up to 260 characters for file and path lengths, Microsoft Excel and older Office version have a lower limit, see KB 326039 for details.
By default, Windows uses a path length limitation (MAX_PATH) of 256 characters: Naming Files, Paths, and Namespaces. To remove this limitation in Windows 10 version 1607 onward, follow the procedure below.
- In the Registry Editor, navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem and select the entry named: LongPathsEnabled.
- Double-click on the LongPathsEnabled entry. In the Value data field, enter a value of 1. This will enable the option for long paths.

Please note that for Windows 11, the above registry entry does not seem to work properly (as it does in Windows 10), as described at: https://answers.microsoft.com/en-us/windows/forum/all/how-to-make-longpathsenabled-work-on-windows-11/ab5897c4-a3c4-4961-ad2d-ceecad66900b.
Refer to my relevant KB post about long file paths in Windows for some more details on the topic.
As per the following thread, the issue is not resolved by Microsoft in Windows 11 and continues to exist as an operating system bug, as discussed at: https://answers.microsoft.com/en-us/windows/forum/all/long-file-path-issues-in-windows-11-pro-with/0c440721-e35a-4b58-9f5a-645656768f9d?page=5. The registry change is not the way to enable long paths with windows 11. Instead run gpedit.msc and edit the following local group policy: System "Configuration>Administrative Templates>System>Filesystem>Enable Win32 long paths" to set it to enabled. If this still does not work in your Windows 11 environment, as of August 2023 you should wait for Microsoft to permanently fix this bug in an upcoming Windows 11 update.