I have an ASP.NET MVC application that allows a user to upload a file that should only contain plain text.
I am looking for a simple approach to verify that a file really only contains text.
For my purposes, I am happy to define text as any of the characters that I can see on my GB QWERTY keyboard.
Business rules mean that my uploaded file will not contain any accented characters, so it does not matter if their code is accepted or rejected.
Approaches still haven't worked:
- Content check; there is nothing good, as it depends on the file extension.
- Check
char.IsControl for each character; there is nothing good, as the file may contain pipe (|) characters, which are considered control characters.
I would prefer not to use the long Regex template to make it work.
source share