https://msdn.microsoft.com/en-us/librar ... s.85).aspx
It should be possible to deal with filesystem paths that are over the old 260 character limit by prepending "\\?\" to the path (or using recent Win10 builds, but assume for the moment that we're not)
E.g. This path is invalid:
Code: Select all
C:\Users\Username\Long Path Test\LongFolderName\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername
Code: Select all
\\?\C:\Users\Username\Long Path Test\LongFolderName\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername\Anotherlongfoldername
Using CreateDirectory on "Long Path Test" and each subfolder in turn eventually results in an apparent success, but the actual folder name created is truncated, and comes out as "Anotherlon". Looking at the entire resulting path, I find it's 257 characters, which is suspiciously close to the old 260 limit. All the subsequent folders fail with the error that there already is a folder of that name.
Has anyone done something similar where CreateDirectory has been used with such long paths? Anything extra you had to do to get it to work?
(These are test folder structures to explore the problem, but the purpose of the program involves syncing data from A to B, and I don't get to choose whether there are long paths on the source. So "don't have long paths" isn't a good option.)
(If you need to create such structures for testing purposes, md "\\?\C:\whatever\folder\you\want" works.)