I've got a string like "Foo: Bar" that I want to use as a filename, but on Windows the ":" char isn't allowed in a filename.
Is there a method that will turn "Foo: Bar" into something like "Foo- Bar"?
cfilenameswindows
I've got a string like "Foo: Bar" that I want to use as a filename, but on Windows the ":" char isn't allowed in a filename.
Is there a method that will turn "Foo: Bar" into something like "Foo- Bar"?
Best Answer
Try something like this:
Edit:
Since
GetInvalidFileNameChars()
will return 10 or 15 chars, it's better to use aStringBuilder
instead of a simple string; the original version will take longer and consume more memory.