I'm looking for a way to avoid System.IO.PathTooLongException. I read that I could put \\?\
in front of a long path.
The problem is that I have FileInfo
objects and I ask me how to add the \\?\
path prefix to my FileInfo
paths without writting useless code.
Note that I have folders with several thousand of files to copy and I don't want that my application takes a lot of useless time during his process.
Thanks.
DirectoryInfo dir = new DirectoryInfo(sourceDirName);
FileInfo[] files = dir.GetFiles(Constants.ALL_FILES, SearchOption.AllDirectories);
foreach (FileInfo file in files)
{
file.CopyTo(destAbsolutePath);
}