I'm trying to find a workaround for the Windows character limitation that doesn't allow a file to be copied if its name is >= 260 characters. According to this MSDN article, if \\?\
is prepended to the file name, this will circumvent the filename length restriction.
I tried this test:
string source = "\\\\?\\C:\\Users\\xxxx\\Documents\\Visual Studio 2013\\Projects\\PDFConverterTester\\PDFConverterTester_BatchGUI\\bin\\Debug\\folder1\\a.txt";
string dest= "\\\\?\\C:\\Users\\xxxx\\Documents\\Visual Studio 2013\\Projects\\PDFConverterTester\\PDFConverterTester_BatchGUI\\bin\\Debug\\folder2\\a.txt";
System.IO.File.Copy(source, dest);
But this threw an exception:
Illegal characters in path.
Should I be applying this prefix in a different way?
Edit: My company's IT policy will not allow me to install any new software without a lengthy review process, meaning that I can't update to 4.6.2. so I'm trying to figure out how to resolve this with Windows API calls from my existing .NET 4.5 installation of Visual Studio.