Alternative to Windows Explorer for long path names

18,416

Solution 1

While NTFS allows paths some 32,000 characters long, you've found the 259-character path length limitation of the Win32 API.

In the Windows API (with some exceptions discussed in the [linked document]), the maximum length for a path is MAX_PATH, which is defined as 260 characters.

(There is additionally a NULL termination character appended to the path, giving us 259 usable characters.)

Because Explorer (and almost all other Windows apps) rely on the Win32 API for filesystem access, it's not practical to get around this limitation even though it is possible:

The Windows API has many functions that also have Unicode versions to permit an extended-length path for a maximum total path length of 32,767 characters. This type of path is composed of components separated by backslashes, each up to the value returned in the lpMaximumComponentLength parameter of the GetVolumeInformation function (this value is commonly 255 characters). To specify an extended-length path, use the "\\?\" prefix. For example, "\\?\D:\very long path".

Unfortunately, you can't just type \\?\D:\very long path in to an Explorer window. The application must be designed to take advantage of these APIs and handle very long path names.

One way to access extended-length paths under Windows is to install Cygwin, a *nix emulation layer for Windows. In my testing, Cygwin does not appear to be limited by MAX_PATH; bash and vi had no problems with paths 2,000 characters long.

Keep in mind that even though you can use bash to browse extended-length paths, you probably won't be able to open files in those paths in regular Windows applications. For example, typing notepad while the working directory is an extended-length path gets you

Error: Current working directory has a path longer than allowed for a Win32 working directory. Can't start native Windows application from here.

And trying notepad "\\?\D:\very long path\file.txt" doesn't work either; it launches, but just says "Can't find file ..." Trying the same with Notepad++ crashes it. (Probably a buffer overflow.)

Your other option to access specific files buried deep within an extended-length path is to shorten the path itself by creating a NTFS junction point. From an elevated command prompt:

D:\> mklink /J jct "\\?\D:\very\long\path"

You can now access the contents of D:\very\long\path\ from D:\jct\. You won't hit any path length problems because as far as Explorer and other apps are concerned, the path is just D:\jct\ (or whatever). The NTFS driver handles redirecting the path (the "reparse point") transparently.

The downside to this approach is obviously that you have to create a junction near the file you want to access; you still can't simply browse the entire directory structure.

Regarding special characters (" * : < > ? \ |), that's simply a no-go. Those characters have special meanings within Windows, so it's not possible to use them within paths. (Cygwin allows you to create files with special characters, but it does so by substituting the characters with special Unicode characters, which it then substitutes back when reading. Viewing these Cygwin-created files under Linux or in Explorer wouldn't look right, since the Unicode characters wouldn't be substituted back.)


All of that said, what are you doing that requires very long paths? Perhaps you could make your life easier by reevaluating what you're doing and avoiding long paths. Chances are, you don't need paths that long anyway.

Solution 2

I tried the 7-Zip file manager and it seems to work fine with long paths.

Solution 3

If you like text mode applications, then FAR Manager may be of interest to you since I've found that it can support deeper directory structures than Windows Explorer can (although there still are some limitations imposed by the underlying Windows OS itself).

This is a native 32-bit/64-bit Windows application that, like Norton Commander (from the days when DOS was the supreme ruler of Operating Systems on the PC), specializes in Directory (a.k.a., "Folder") and File management.

I've even seen reports of it being used as a replacement for Windows Explorer, but I haven't tried this because I'm quite pleased with it in the context of using it as an application. The screenshot I included below features the "Directory Tree" feature on the right-hand side, which is activated by pressing F9 (Menu bar), then "R" (Right Panel menu), followed by "T" (Tree Panel mode), which may be of particular interest to you...

  FAR Manager (free and open source)
  http://www.farmanager.com/

enter image description here

Solution 4

there are some alternatives, but I did not check how deep the directories could be.

I tried Explorer ++, opensource and portable

Explorer ++ screenshot

and curretly use Cubic Explorer, also opensource:

Cubicexplorer screenshot

Solution 5

Have you tried Total Commander? It’s shareware. It seems to deal with long path names and is a very useful file manager in general.

Share:
18,416

Related videos on Youtube

baz
Author by

baz

Elitists are oppressive, anti-intellectual, ultra-conservative, and cancerous to the society, environment, and humanity. Please help make Stack Exchange a better place. Expose elite supremacy, elitist brutality, and moderation injustice to https://stackoverflow.com/contact (complicit community managers), in comments, to meta, outside Stack Exchange, and by legal actions. Push back and don't let them normalize their behaviors. Changes always happen from the bottom up. Thank you very much! Just a curious self learner. Almost always upvote replies. Thanks for enlightenment! Meanwhile, Corruption and abuses have been rampantly coming from elitists. Supportive comments have been removed and attacks are kept to control the direction of discourse. Outright vicious comments have been removed only to conceal atrocities. Systematic discrimination has been made into policies. Countless users have been harassed, persecuted, and suffocated. Q&amp;A sites are for everyone to learn and grow, not for elitists to indulge abusive oppression, and cover up for each other. https://softwareengineering.stackexchange.com/posts/419086/revisions https://math.meta.stackexchange.com/q/32539/ (https://i.stack.imgur.com/4knYh.png) and https://math.meta.stackexchange.com/q/32548/ (https://i.stack.imgur.com/9gaZ2.png) https://meta.stackexchange.com/posts/353417/timeline (The moderators defended continuous harassment comments showing no reading and understanding of my post) https://cs.stackexchange.com/posts/125651/timeline (a PLT academic had trouble with the books I am reading and disparaged my self learning posts, and a moderator with long abusive history added more insults.) https://stackoverflow.com/posts/61679659/revisions (homework libels) Much more that have happened.

Updated on September 18, 2022

Comments

  • baz
    baz over 1 year

    Update:

    1. I found that not only Windows Explorer but also other software suffers from too long path names. For example, in Firefox, when I save a webpage into a directory, I still cannot do it if its name or path name is too long. Does Firefox also rely on Windows Explorer? How can I solve that problem too?

    2. I have tried the software recommended in the two replies. None of them can access a long path. Is the Long path problem inherent to Windows OS, regardless of which program to browse directories? If yes, does it mean there is no way to get around it?

    Original: I have two OSes installed on my laptop: Windows 7 and Ubuntu 10.10. They share a partition.

    In Ubuntu, by using Nautilus, I can create directories that are located very deep in the path hierarchy on the shared partition. But when switching to Windows, Windows Explorer does not allow accessing directories that are located too deep, i.e. having too long path name.

    Also Windows Explorer seems not able to access files and directorates created under Ubuntu with special characters in directory and file names.

    I was wondering what can solve the problem in Windows? For example, are there other alternative software to replace Windows Explorer?

    • James P
      James P almost 13 years
      What file system did you use for the shared partition (FAT32, NTFS) ?
    • baz
      baz almost 13 years
      @James: ntfs...
    • cjb110
      cjb110 almost 8 years
      I would ask why you need this length of path or depth? solving whatever led to you hitting the 259 limit is likely easier than making Windows work around it.
  • baz
    baz almost 13 years
    Thanks! I found that not only Windows Explorer but also other software suffers from too long path names. For example, in Firefox, I would like to save a webpage into a directory, I still cannot open the directory if its name or path name is too long. . Does Firefox also rely on Windows Explorer? How can I solve that problem too?
  • baz
    baz almost 13 years
    Thanks! (1) I tried FAR before. There are two questions. I feel the dark blue strain my eyes, so can it be changed? Also I wonder how to choose an application to open a file which can be either not recognized or be opened in several different applications. (2) I found that not only Windows Explorer but also other software suffers from too long path names. For example, in Firefox, I would like to save a webpage into a directory, I still cannot open the directory if its name or path name is too long. Does Firefox also rely on Windows Explorer? How can I solve that problem too?
  • Randolf Richardson
    Randolf Richardson almost 13 years
    Yes, the colour can be changed: F9 (Menu bar), "O" (Options menu), "L" (Colours).
  • Randolf Richardson
    Randolf Richardson almost 13 years
    I don't completely understand the second question about "...how to choose an application to open a file..." but if you press Shift-Enter on a file it will rely on Windows' File Associations to open it (instead of trying to find a built-in feature or FAR Manager plug-in to handle it).
  • baz
    baz almost 13 years
    Thanks! For the question of opening files, I meant what if a file is either not recognized (ie not associated with a program), or I want to open it with another program different from the associated one?
  • Randolf Richardson
    Randolf Richardson almost 13 years
    Use Shift-Enter, which will cause Windows to attempt to open it; since it will be unrecognized, you will be presented with the usual prompt to select an application.
  • baz
    baz almost 13 years
    @Randolf: Thanks! I have tried the software recommended in your and Juhele's posts. Execept FAR, non of them can access a long path, while FAR can open such a directory, it cannot open a file under it. Is the Long path problem inherent to Windows OS, regardless of which program to browse directories? If yes, does it mean there is no way to get around it?
  • Moab
    Moab almost 13 years
    @ Juhele, +1 for Cubic Software
  • xaedes
    xaedes over 10 years
    I just tried Explorer++ and Cubic Explorer. But both seem to not support long path names.
  • Aaron
    Aaron over 7 years
    It seems like this answer says "No software exists that does what you are looking for" but not explictly
  • Omaer
    Omaer over 6 years
    Brilliant! Hidden gem that I had on my computer and just didn't think to try. Bonus: I had a long path on a network share - and I noticed that the performance on the 7 Zip File Manager is crazy fast vs the slow performance on Windows Explorer
  • Nicolas Raoul
    Nicolas Raoul over 5 years
    Explorer++ does not support long paths, it is a documented issue: github.com/derceg/explorerplusplus/issues/60
  • Vijay
    Vijay about 4 years
    while i love dopus, your are answer is not at all relevant to the current problem at hand. the path limit is a limitation of the OS and not the application. I believe they have resolved this in win10.