title: How to deal with files with a name longer than 259 characters?
body: <p>I'm working on an application which walks through every file in some directories and does some actions with those files. Among others, I must retrieve the file size and the date when this file was modified.</p>
  
  <p>Some file full names (directory + file name) being too long, I couldn't use .NET Framework <code>FileInfo</code>, which is limited to <code>MAX_PATH</code> (260 characters). Many web sources advised to use native Win32 functions through P/Invoke to access the files whose names are too long.</p>
  
  <p>Currently, the exactly same problem seems to arise with Win32 functions. For example, <code>GetFileAttributesEx</code> (kernel32.dll) fails with Win32 error 3 ERROR_PATH_NOT_FOUND for the path of 270 bytes.</p>
  
  <p>The very same file can successfully be opened from Notepad2 and successfully displayed with Windows Explorer (but Visual Studio 2010 for example fails to open it because of the 259 characters limit¹).</p>
  
  <p>What can I do to be able to access a file when the file path is 270 characters long?</p>
  
  <p>Notes:</p>
  
  <ul>
  <li><p>Removing or ignoring files with the file path length longer than 259 characters is not a solution.</p></li>
  <li><p>I'm looking for Unicode-compatible solutions only.</p></li>
  <li><p>The application will run under Windows 2008/Vista or later with .NET Framework 4 installed.</p></li>
  </ul>
  
  <hr>
  
  <p><sup>¹ Surprisingly, Microsoft Word 2007 fails, complaining that "the floppy disk is too small" on a computer which don't have any floppy drive, or that "RAM memory is low" when there is 4 GB of RAM left, or finally that "antivirus software [...] needs to be updated". Will they stop one day displaying such stupidly meaningless errors at least in such key products as Microsoft Office?</sup></p>