Notifications
Clear all
[Closed] illegal character filter
Mar 06, 2012 8:07 am
What’s the easiest way to ensure a user doesn’t place any illegal characters in a filename?
Thnx
2 Replies
Mar 06, 2012 8:07 am
there are many ways to go about this. Here is one:
fn validateFilename f =
(
for c in ((dotnetclass "System.IO.Path").GetInvalidFileNameChars()) do f = substituteString f c "_"
f
)
Mar 06, 2012 8:07 am
if i need just to check that user doesn’t type illegal characters i would do it with regex:
http://stackoverflow.com/questions/62771/how-check-if-given-string-is-legal-allowed-file-name-under-windows