In C#, I have a filename that needs to converted to be double-escaped (because I feed this string into a regex).
In other words, if I have:
FileInfo file = new FileInfo(@"c:\windows\foo.txt");
string fileName = file.FullName;
fileName
is: c:\\\\windows\\\\foo.txt
But I need to convert this to have sequences of two literal backslashes \\ in the fileName.
fileName needs to be @"c:\\\\windows\\\\foo.txt"
, or "c:\\\\\\\\windows\\\\\\\\foo.txt"
.
Is there an easy way to make this conversion?