As you may already know and if not, you will find out by reading my articles, I like mostly to treat real problems and errors you get in a live environment. When we’re talking about problems and errors I am not a big fan of documentation because most of the times, it doesn’t happen as they describe in theory.
Some of you may qualify this as ignorance or lack of knowledge but it isn’t the case, because I for one like to read and I’m more than happy to discuss anything with anyone who comes with another point of view or a different approach.
According to Windows API, it is said, in theory, that the true possible character length of a path is somewhere a bit higher than 32,000 characters. Windows maximum path length again in theory, allows you to reach a character number around 260 characters.
Due to different other dependencies the 260 length will never be reachable. For example, on a Windows XP system you will have most of the times a max length in file or path name of 248. However, it is said that it should be 255 characters (even if I never reached this value) along with a hidden one, which is the ending tag slash. Even if system is not displaying it or you can’t see it, it doesn’t matter, it is not there. The system uses it when manipulating files.
Once again I tried it for myself and I could reach (despite the theory of Windows maximum path length) to a maximum number of 248 as you will see from below example.
All of the information you need is spread all over the Internet, but most of them deal with manuals and theories instead of the real live environment. You can read such an “official” article about Windows API and Windows maximum path length in here: http://msdn.microsoft.com/en-us/library/aa365247.aspx but again, most of the things said in there will never fit a live environment.
I tried for myself and created a few folders on a Windows XP SP 3, and this is not the first time I reach this limit but I just wanna bring it to the attention once again, because I do know there are still people who don’t know how to overcome this Windows maximum path length problem.
The details on this picture refer to the fact that we have 6 folders, each with a 40 character length, so that’s 240 characters in one shot. Then, we have the root path which in our case is C:\ making another 3 characters plus the 5 slash separators between the 6 folders. This is a total of 248 characters, as you can see below.
In above picture I used Notepad++ to count the actual characters so you can easier see what I am writing about. With green I have highlighted the actual length of the path: “C:\qwertyuiop1234567890qwertyuiop1234567890\qwertyuiop1234567890
which is also the real Windows maximum path length. The red highlighted part is where my cursor was, the next column, that would be the next character after the last one in the path.
There will come a day when you will get the same problem on the network too, especially if you work in the IT field or offer support to users that use a network environment or network shares. They or you will find yourself in such a position that you will get errors like “The system cannot find the path specified”. Yet, it is not the only way that this error can be triggered. This can happen when you try to save to a file located in a deep path on local or on the network, it can also happen when you try to create files or folders and other situations. Basically, you will have to think and remember this Windows limitation and to take it as a possible cause for a problem that will give as result errors like the ones presented or saying that destination is unreachable, file cannot be located and so on.
Note: There are times when you could get similar errors if you use characters not allowed, like characters in other language, for example Romanian (â, ã) or Japanese.
To bypass this, you can use SUBST or NET USE.
Using SUBST we have:
And now, we can create or save new files to this location as you can see below:
Or using NET USE for a network drive:
NET USE Q: \path to the file (for example \serv1\share\marketing\insert the rest of the path here until 248 characters here).
When this is done, you can actually work in that file without any other Windows maximum path length error for that location.
Keep in mind that I used Q as the letter for my commands because that’s what I have free on my computer. You can use any letter you want as long as it is not assigned to any drive on your computer.
If you have a different case or find some other case that will not fit my description, do share please so I can do a research.