0

I have a string which contains file name. I want to check whether it is valid or not. I don't know how to compare a single string with list.

Ex.

string fileName = "my\file.jpg";  //it is invalid file name as it contain \
List<string> invalidCharacter = new List<string>();
invalidCharacter.Add("\");
invalidCharacter.Add("<");
invalidCharacter.Add(">");
invalidCharacter.Add("?");

I want to check whether fileName contains any character of invalidCharacter list. I have thousands of such name. So, I can not use loop of list for compare every string.

Can anybody please suggest better way to compare string with list?

Nanji Mange
  • 2,155
  • 4
  • 29
  • 63

0 Answers0