c# - How to create directory exceeding MAX_PATH -


for testing purpose, create on disk directory exceeds windows max_path limit. how can that?

(i tried powershell, cmd, windows explorer => it's blocked.)

edited: use of zlpiohelper zetalongpaths library allows whereas standard directory class throws dreaded exception:

        static void main(string[] args)     {         var path = @"d:\temp\";         var dirname = "looooooooooooooooooooooooooooooooooooooooooooongsubdirectory";         while (path.length <= 280)         {             path = path.combine(path, dirname);             zlpiohelper.createdirectory(path); //directory.createdirectory(path);         }         console.writeline(path);         console.readline();     } 

in win32 need use special "\\?\" prefix allow longer file names.

see: http://msdn.microsoft.com/en-us/library/aa365247.aspx

for file i/o, "\\?\" prefix path string tells windows apis disable string parsing , send string follows straight file system. example, if file system supports large paths , file names, can exceed max_path limits otherwise enforced windows apis. more information normal maximum path limitation, see previous section maximum path length limitation.

as using c# try library save having pinvokes win32 file api , adding prefix paths.


Comments