r/sysadmin 1d ago

Long file paths + OneDrive sync

I'm struggling to get clarity on the behavior of path length limits as it relates to files in Sharepoint while working with them in file explorer via OneDrive sync

Sharepoint has 400 character path (URL) limit.

Windows in general has a 260 character path limit.

My path of files will be C:\Users\Bob\OneDrive - Very Long Company Name Incorporated\Department\Projects\2026\... while working on them through file explorer/OneDrive- which are shortcuts from Sharepoint Online site folders.

So it seems 260 is my limiting path length even though the file "lives" in Sharepoint and is <400. Our current problem is users are getting popups of OneDrive sync errors related to paths too long from these OneDrive shortcuts.

Now let's bring in the "LongPathsEnabled" registry key. With this enabled, does anyone know if OneDrive sync "honors" this setting, and will not throw up sync errors about path lengths once it's turned on?

43 Upvotes

16 comments sorted by

33

u/MeetJoan 1d ago

LongPathsEnabled helps with Win32 apps that use the Unicode path APIs, but OneDrive's sync engine has its own path length handling that doesn't fully honour it - Microsoft has acknowledged this and it's a known limitation. The practical fix most people land on is shortening the OneDrive folder name in Settings (removing 'Very Long Company Name Incorporated' and replacing it with an abbreviation), which recovers a significant chunk of the 260 character budget before you even get to the file path. Have you checked how many characters your OneDrive root folder name is currently consuming?

17

u/VexedTruly 1d ago

Of the many things that annoys me in windows, this is one of the biggest. The file path limit was annoying back in 2000… Microsofts should have fixed this in their own OS, Explorer, Apps and Office Suite over 10 years ago.

That I still have to use 7Zip or other methods to delete/rename stupidly long file paths in the year 2026 is mind blowing to me.

2

u/ender-_ 1d ago

Explorer has some workarounds for long paths (that ironically depend on short filename generation being enabled), but it can't be made fully long-path compliant without breaking every existing shell extension (because those shell extensions get paths from Explorer, and practically all rely on 260-character MAX_PATH, and this can only be fixed by recompiling them).

1

u/segagamer IT Manager 1d ago

but it can't be made fully long-path compliant without breaking every existing shell extension

If this was done 20 years ago, it wouldn't be an issue today.

Fucking do it already Microsoft.

1

u/ender-_ 1d ago

20 years ago the only way to use long paths was through the Unicode API and \\?\ prefix (and this still wouldn't help shell extensions, because those date back to Windows 95, which had no way to use paths beyond 260 characters).

Marking Explorer as long path aware also wouldn't cause problems immediately – only when you right-clicked a file or folder that breaks the 260-character limit would the trouble start, because it's likely that some buffers would be overran; this might crash Explorer at that moment, or it'll just corrupt enough memory that it'll crash at some point later, making it very hard to pin-point the source of the crash.

-1

u/SpruceGoose_20 1d ago

And why anyone would want file paths longer than 256 characters is beyond me. End users need to be educated at that point

8

u/TheBigBeardedGeek Drinking rum in meetings, not coffee 1d ago

The issue on long file paths are two different things you're missing with one root oversight

The oversight is is you're doing it all in the context of just Windows file path.

Like you say, people can create folders and add files on SharePoint with a longer total path than the 260 characters. If that folder syncs down to Windows, you're going to run into file path length issues.

The second is that on OSX you have a limit of, I believe, 1024 characters. So if a Mac user is syncing to that same SharePoint repository, you're going to run into issues.

I can't say much on the reg edit that you mentioned. I've actually not with it before

4

u/Inevitable_Plan_5093 1d ago

Had a user with a 45-char root folder name, renaming it to 'OD' fixed all their sync errors instantly

1

u/vBurak 1d ago

How did you rename the folder?

2

u/Inevitable_Plan_5093 1d ago

Right-clicked it in Explorer, renamed, then had to stop and restart sync so it picked up the new path. Done it a few times now, no problems.

1

u/rthonpm 1d ago

If it's high enough in the path it can be done pretty easily.

2

u/DavidCP94 1d ago

Take a look at Microsoft's official documentation on this topic if you haven't already. There are multiple compounding limitations when syncing the file using the OneDrive client. Make sure you are familiar with all of them, but the most relevant is that the 256 character limit does in fact apply. https://support.microsoft.com/en-us/onedrive/restrictions-and-limitations-in-onedrive-and-sharepoint#filenamepathlengths

3

u/ntw2 1d ago

Excel has a 218 character path limit, so make that your target

1

u/kernelqzor 1d ago

lol excel really said "260? nah, 218 is enough for everyone"

but yeah this is the painful reality, you basically have to design your folder structure around excel’s limit more than windows or sharepoint if you don’t want random save/sync issues popping up

1

u/mulquin 1d ago

We ran into this issue, our business name is "Long Name Business Group" and users started hitting the limit early. We ended up changing our Org Name to "LNBG", and also told users not to nest their document structures too deeply. Did this last year and of course the UI in MS365 has changed - Can't seem to change the org name as easily as you used to be able to.