Someone just came to me with an issue they were having with a classic ASP application that is using the FileSystemObject to display files as links. Everything was working great, until all of the sudden some files were not showing up. Come to find out, the root cause was due to the fact that the FileSystemObject, just like Windows Explorer, is limited to a MAX_PATH of 260 characters for any full path and file name. Since there was already error handling (and hiding) in the Classic ASP code, this was not obvious at first. What really made it very obvious was when Windows Explorer wouldn't allow a file to be renamed past the 260 character limit. Windows Vista Ultimate RTM - Windows Explorer has the same limitation. The files that were exceeding this limit had been copied to this location via an automated Robocopy.

I whipped up a proof of concept .NET ASPX WebForm using DirectoryInfo - GetFileSystemInfos(). But alas, with this method it was generating the following exception: Exception Details: System.IO.PathTooLongException: The path is too long after being fully qualified. Make sure path is less than 260 characters. After further research, the only solution I discovered was to use the Windows API via PInvoke of CreatFileEx. This API utilizes unicode for the path and can handle up to 32,000 characters. Supposedly appending the string "\\\\?\\" in front of the path should force that path to be sent as unicode, but I was unable to get this to work successfully. Instead, this was causing an invalid character exception. I will continue looking at this alternative considering the preformance improvements that would come along with it. It's just a matter of getting the unicode part working, here's a resource I discovered that showed some VB.NET code - http://vbnet.mvps.org/index.html?code/fileapi/fsoapicompare.htm. After more trial and error on my own, I did finally discover the easiest work around and that is to simply use these two methods of the .NET framework instead: System.IO.Directory.GetFiles() System.IO.Directory.GetDirectories()

They both return back string arrays of the full path of the files and directories respectfully. As long as you don't need the additional properties, as in this case, this is the easiest solution to the problem.