Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I can't think of any other way off the top of my head other than using reflection, or using a library or P/Invoke to use the Windows APIs that support long paths and manually check length. The full path is stored in a <code>protected string</code> field called <code>FullPath</code></p> <pre><code>foreach(var dir in new DirectoryInfo (@"D:\longpaths") .GetFileSystemInfos("*.*", SearchOption.AllDirectories)) { try { Console.WriteLine(dir.FullName); } catch (PathTooLongException) { FieldInfo fld = typeof(FileSystemInfo).GetField( "FullPath", BindingFlags.Instance | BindingFlags.NonPublic); Console.WriteLine(fld.GetValue(dir)); // outputs your long path } } </code></pre> <p>If you're trying to <em>actually</em> do something with the files and not just check file length, I would suggest using a library like this one <a href="http://bcl.codeplex.com/wikipage?title=Long%20Path%20Samples&amp;referringTitle=Long%20Path" rel="noreferrer">from the BCL team at Microsoft</a>, however it doesn't create <code>DirectoryInfos</code>, <code>FileInfo</code> or <code>FileSystemInfo</code>, only strings. So it's might not be a drop-in replacement for your code it seems.</p> <p>As for the answer to your second question, I recommend reading <a href="http://blogs.msdn.com/b/bclteam/archive/2007/02/13/long-paths-in-net-part-1-of-3-kim-hamilton.aspx" rel="noreferrer">this blog post</a> dealing with long paths in .NET. This is a quote from it that explains why they haven't been quick to add long path support in .NET.</p> <blockquote> <p>Very few people complain about a 32K limit, so, problem solved? Not quite. There are several reasons we were reluctant to add long paths in the past, and why we’re still careful about it, related to security, inconsistent support in the Windows APIs of the \?\ syntax, and app compatibility.</p> </blockquote> <p>It's a 3 part series and explains a few reasons why the API is the way it is and why the limitation is there.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload