0

I'm downloading images from various pages. I'd like for the program to take the address of the page and filter out any letters that are not suitable for a file name (such as / or ?).

I know many of these symbols so I could just put them in a hardcoded list and remove them from the string by looping string.replace but I probably don't know all of them and googling didn't yield an "official" list of what symbols microsoft deems suitable.

Knowing .net though, I figured there is probably a function that can either fix the string or identify the bad symbols for filename purposes, is there any?

user81993
  • 5,628
  • 4
  • 30
  • 55
  • I don't have such a list on hand, but I strongly urge you to use a whitelist rather than a blacklist. That is, specify the valid characters, and allow _only_ those through, as opposed to specifying the invalid characters. – Chris Jester-Young Jan 25 '15 at 05:49
  • 2
    Possible duplicate : http://stackoverflow.com/questions/309485/c-sharp-sanitize-file-name – dotnetstep Jan 25 '15 at 05:50

0 Answers0