I'm dealing with a perplexing issue involving OneDrive and long file paths. When someone copies a file to a OneDrive folder, the combined length of the path and filename sometimes exceeds 256 characters. Despite having enabled long paths via the registry setting "LongPathsEnabled" under the control settings, the file refuses to open or even preview. Instead, it throws an error stating: "The file you are attempting to preview could harm your computer. If you trust the file and the source you received it from, open it to view its contents." Strangely enough, if I shorten the path to 254 characters, everything works fine. I'm trying to understand why OneDrive behaves this way and if there's a workaround apart from simply shortening folder names. I've noticed that when creating shortcuts, OneDrive does truncate long paths in a confusing manner. Has anyone else experienced this or found a solution?
5 Answers
For what it's worth, it's often easier to just rebuild the folder structure rather than dealing with long paths. You might even advise renaming the tenant with just the initials instead of the full company name to save space in the path. Like changing "Example Company - Shared Files" to "EC - Shared Files". It might make a big difference.
It seems to be a limitation in OneDrive. I found this official link about their restrictions: https://support.microsoft.com/en-us/office/restrictions-and-limitations-in-onedrive-and-sharepoint-64883a5d-228e-48f5-b3d2-eb39e07630fa. They mention that the path limit is around 400 characters, but I’ve seen it fail around 257 characters. It’s definitely confusing!
Honestly, it's best to avoid long paths altogether. Just because it works sometimes in specific scenarios doesn’t guarantee it'll work everywhere, especially with older software. I’d suggest talking to the engineer about tidying up their folder structure. It’ll save you tons of troubleshooting time in the long run.
Apparently, the 260 character limit includes the path leading to the file, so "C:
You are correct that some applications need to support long paths for them to work effectively. Even Microsoft apps can struggle despite the registry tweak. Plus, OneDrive itself seems to impose its own limitations. You should encourage better structures; many are overly complicated. For example, instead of having redundant names like accounting department2025 reportsAP 2025, simplifying can really help.
Related Questions
Can't Load PhpMyadmin On After Server Update
Redirect www to non-www in Apache Conf
How To Check If Your SSL Cert Is SHA 1
Windows TrackPad Gestures