I have files on my hard drive that throw a PathTooLongException
when I access the Fullname
property of a FileSystemInfo
object. Is there any way around this (excluding renaming the files which is not an option)?
http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx#maxpath mentioned by other answers suggests putting a "\?\" prefix on the file name but in this case the DirectoryInfo.GetFileSystemInfos()
is responsible for creating the FileSystemInfo
objects and DirectoryInfo
doesn't accept that prefix so there's no way to use it.
The answer " PathTooLongException in C# code " doesn't help because this is a multi-threaded application and I can't keep changing the current application path.
Do I really have to do everything with PInvoke
just to be able to read every file on the hard drive?