Software & OS

Path Too Long on Windows: Why 260 Characters, and 6 Ways Around It

Windows says a path is too long when the full path, from the drive letter to the end of the file name, goes past 260 characters, the MAX_PATH limit that most programs still use. The reliable fix is to make the path shorter (move or rename a parent folder, or map a deep folder to a drive letter with subst); the LongPathsEnabled setting helps only programs written to support long paths.

Why the limit is 260 characters

In the Windows API, MAX_PATH is defined as 260 characters. Microsoft's documentation breaks a maximal local path down as the drive letter, a colon, a backslash, up to 256 characters of folder and file names, and a terminating null character. So D:\ plus 256 characters is the most a classic program can handle. Two further limits apply:

  • Each single folder or file name is commonly limited to 255 characters (the file system reports the exact value).
  • When a program creates a folder, the path must leave room for an 8.3-style file name inside it, so a directory path can be at most 248 characters (260 minus 12).

NTFS itself can store much longer paths, about 32,767 characters. The 260 limit lives in the programs and the API calls they use, which is why one program can create a file that another program then can't open, copy or delete.

What the error looks like

Each program reports it differently, and several don't mention length at all. These were reproduced on Windows 11 with long paths not enabled, using a 334-character path inside a test folder:

ToolMessage
PowerShell 5.1 (New-Item, Set-Content, Remove-Item)Could not find a part of the path 'C:\work\...'
Command Prompt (type)The system cannot find the path specified.
Python 3.12FileNotFoundError: [Errno 2] No such file or directory: 'C:\\work\\...'
Git for Windows 2.45warning: could not open directory '...': Filename too long

The misleading "not found" wording is common: the file exists, but the program never gets far enough to see it. If a file you can see in a listing "doesn't exist" when you open it, count the characters in its full path.

To find the longest paths under a folder, in PowerShell (replace C:\work with your folder):

Get-ChildItem -LiteralPath '\\?\C:\work' -Recurse -File -ErrorAction SilentlyContinue |
  Sort-Object { $_.FullName.Length } -Descending |
  Select-Object -First 10 @{n='Length';e={$_.FullName.Length - 4}}, FullName

The \\?\ prefix (explained in Fix 4) matters here. In our test, Windows PowerShell 5.1 without it silently skipped the over-long file, so the very files you are looking for never appeared in the list. The - 4 subtracts the prefix from the reported length.

Fix 1: Shorten the path

This works for every program, with no settings changed. Paths get long because a long name sits inside a deep folder, so shorten whichever part you control:

  • Move the project or extracted archive closer to the drive root: C:\src\project instead of C:\Users\alex\OneDrive - Company Name\Documents\Projects\2026\Client\project. That one change takes the folder from 76 characters to 14, and every path inside it shrinks by the same 62.
  • Rename a long parent folder. Renaming one folder near the top shortens every path below it.
  • When extracting a ZIP file, extract to a short folder such as C:\x. Archives often contain a top folder with the archive's own long name, and the default destination repeats it.

Fix 2: Map a deep folder to a drive letter with subst

If you can't move the folder (a synced folder, a path a program expects), subst gives it a short drive letter. Every path below it gets shorter by the length of the folder you mapped:

subst X: "C:\Users\alex\OneDrive - Company Name\Documents\Projects\2026"
X:

Now the file is reachable as X:\Client\project\..., and you can open, copy, rename or delete it through X:. Remove the mapping when you're done:

subst X: /d

Microsoft's reference warns not to run chkdsk, format, label and a few other disk commands against a subst drive.

Fix 3: Delete a folder that's too long to delete

When a deep tree refuses to be deleted, two built-in commands handled it in our test, where Remove-Item without a prefix failed. From Command Prompt:

rd /s /q "C:\work\deep-folder"

Or the robocopy trick: mirror an empty folder over the problem folder, which deletes everything inside it. robocopy's /mir means "/e plus /purge", and /purge deletes destination files that aren't in the source:

mkdir C:\empty
robocopy C:\empty "C:\work\deep-folder" /MIR
rd C:\empty
rd "C:\work\deep-folder"

Expect exit code 2 from robocopy here; Microsoft documents it as "additional files in the destination directory", which is exactly what was removed. robocopy supports paths longer than 256 characters by default (its /256 option turns that off), so it is also the built-in tool for copying long-path trees. Double-check the destination path before running /MIR: it deletes whatever is in the destination and not in the source.

Fix 4: Use the \\?\ prefix in PowerShell and scripts

Prefixing an absolute path with \\?\ tells Windows to pass it through with minimal processing, which lifts the limit to about 32,767 characters for programs using the Unicode file APIs. In PowerShell 5.1, the same commands that failed above worked with the prefix and -LiteralPath:

Remove-Item -LiteralPath '\\?\C:\work\deep-folder' -Recurse -Force
Get-Content -LiteralPath '\\?\C:\work\deep-folder\...\report.txt'

Python accepts it too: open(r'\\?\C:\work\deep-folder\...\report.txt') read the file that failed without the prefix. The prefix has rules: the path must be absolute, must use backslashes, and can't contain . or ... Network shares use \\?\UNC\server\share\....

Fix 5: Git "Filename too long"

Git for Windows has its own switch, separate from the Windows setting. It's off by default; git help config explains that's because Windows Explorer, cmd.exe and parts of the Git for Windows toolchain don't support long paths. Turn it on for one repository, or for your user:

git config core.longpaths true
git config --global core.longpaths true

For a clone that fails part-way, pass it on the command line: git clone -c core.longpaths=true <url>. In the test above, the same git add that printed "Filename too long" succeeded with core.longpaths=true. Cloning into a short folder such as C:\src avoids the problem entirely and keeps the files usable by every other tool.

Fix 6: LongPathsEnabled, and what it really does

Windows 10 version 1607 and later can lift MAX_PATH for common file functions, but Microsoft is explicit that two conditions must both be met:

  1. The registry value LongPathsEnabled (type REG_DWORD) under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem is set to 1. The same setting is available in Group Policy at Computer Configuration > Administrative Templates > System > Filesystem > Enable Win32 long paths.
  2. The program's application manifest declares longPathAware.

The documentation's own warning: enabling the setting "will only affect applications that have been modified to take advantage of the new feature." It needs administrator rights, and processes read it once, so a restart may be needed before every program sees it. To check the current value without changing anything:

Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name LongPathsEnabled

Example output on a machine where it is off (1 means on):

LongPathsEnabled : 0

Python is one program that opts in. Its documentation says that once the policy or registry value is set and the machine rebooted, open(), the os module and most path functions accept paths longer than 260 characters with no further configuration. If you change this on a work machine, it's usually managed by Group Policy, so ask IT rather than editing the registry yourself.

If it still fails

Check whether the limit is the path or a single name: one folder or file name over 255 characters fails even with every long-path setting on. Check whether the file sits on a network share or a sync client, which can add their own limits. And if a program still refuses long paths after you've enabled the setting and restarted, that program isn't long-path aware: shorten the path or use subst. For finding which files are taking space in deep folders, see how to find large files; for more Command Prompt basics, see the CMD commands list.

Frequently asked questions

What is the maximum path length in Windows?
For most programs it is 260 characters (MAX_PATH), counting the drive letter, colon, backslashes and a terminating null, which leaves 256 characters for the folders and file name after C:\. Programs that use the \\?\ prefix, or that opt in to long paths on Windows 10 version 1607 or later, can use about 32,767 characters. Each individual folder or file name is commonly limited to 255 characters.
Does enabling LongPathsEnabled fix File Explorer?
Not reliably. Microsoft's documentation says the setting only affects applications that declare themselves long-path aware in their manifest. Programs that haven't been updated keep the 260-character limit whatever the setting is, so the practical fix for a stubborn file is still to shorten the path.
Is it safe to enable long paths in Windows?
The setting itself only lifts a limit for programs that ask for it, and it requires administrator rights to change. The practical risk is creating files that older programs, including some backup and sync tools, cannot open, copy or delete. If you share files with such software, keep paths short even if your own tools can cope.
How long is my path?
In PowerShell, run (Resolve-Path 'C:\your\file.txt').Path.Length. To list the longest paths under a folder, run Get-ChildItem -Recurse on the folder with the extended-length prefix in front of it, because Windows PowerShell 5.1 silently skips over-long paths without it. Long names inside a folder that is itself deep, such as OneDrive or a project folder under Documents, are the usual cause.

Sources