fileName = fileName.Replace(":", "-")
However, ":" is not the only illegal character for Windows. You will also have to contact:
/, \, :, *, ?, ", <, > and |
They are contained in System.IO.Path.GetInvalidFileNameChars ();
Also (on Windows), "." cannot be the only character in the file name (both ".", "..", "...", etc. are not valid). Be careful when naming files with "." , For example:
echo "test" > .test.
Generates a file named ".test"
Finally, if you really want to do something right, there are some special file names that you need to look at from behind. On Windows, you cannot create files with the name:
CON, PRN, AUX, CLOCK$, NUL COM0, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9 LPT0, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9.