0

I am checking the csv extension as below:

   string extension = System.IO.Path.GetExtension(UploadFile.PostedFile.FileName);
      //check file extension
   if (!(extension == ".csv"))
    {
    }

should i need to check for the .CSV too? like:

 if (!(extension == ".csv" || extension ==".CSV"))
Harshit
  • 149
  • 3
  • 14

1 Answers1

0

Extension can be null, so I'd used something like ".csv".Equals(extension, StringComparer.OrdinalIgnoreCase)

Yuriy Faktorovich
  • 67,283
  • 14
  • 105
  • 142