clear string from signs which cant be used in filename
Im generating various strings 开发者_如何学Goand then I want to save files with generated strings as filenames. Sometimes generated string has got various chars which arent allowed to use in filename.
Is there any ready to use class or sth which can clean up string from such characters ?
Have a look at
Path.GetInvalidPathChars() and Path.GetInvalidFileNameChars()
You can can the list of invalid characters from the Path
class - specifically the GetInvalidFileNameChars
and GetInvalidPathChars
methods.
You can use these in conjunction with the different string
methods to cleanup the string.
精彩评论