For testing purpose, I would like to create on disk a directory which exceeds the Windows MAX_PATH limit. How can I do that?
(I tried Powershell, cmd, windows explorer => it's blocked.)
Edited: The use of ZlpIOHelper from ZetaLongPaths library allows to do that whereas the standard Directory class throws the 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 you need to use the special "\\?\" prefix to allow for longer file names.
See: http://msdn.microsoft.com/en-us/library/aa365247.aspx
As you are using C# then try this library which will save you having to do all the PInvokes to the WIN32 file API and adding the prefix to the paths.