JustCoding,
Do you want non-numeric characters, or that range of characters?
Either way, you will have to read through the file character by character,
and then check to see if the character is a number. You can do this by
getting the character and then calling the IsNumeric method on the
character. If it returns false, you have an error.
If the file isn't too big, and you can load it into a string, you could
also use a regular expression to do this, searching for all characters
that aren't in the range you are looking for (something like the negative
of '[0-9]*' I think, I'm not that experienced with regular expressions).
If you get a match, it is an error.
If the file is particularly large though, loading the contents into a
string will be an issue, and you will see performance suffer.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
JustCoding said:
In C# how can I check for non-numeric characters in a file?
example: if the file has !@#$%^ in it, how can I check for that and
create an error message for that file?