I already gone through some question in StackOverflow regarding this but nothing helped much in my case.
I want to restrict the user to provide a filename that shoul
Copied from @Engineer for future reference as the dot was not escaped (as it should) in the most voted answer.
This is the correct expression:
string regex = @"^[\w\-\. ]+$";