• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

Using Regular Expression to Validate File in the FileUpload Control

Hello and how is it? Quick question and sorry to bother everyone with this, but I am not finding on the Web what I am looking for. I am using the FileUpload control and I want to make sure the user is going pick a certain file. For example the file maybe File34455_349943 or TextFile498595_93493. There is no extensions so cannot match by the extension. I just want to make sure they are picking files with "File" in the filename. I could care less what else is apart of the filename. I am not sure of the regular expression to use because of the path of the file being inserted into the text box. Thanks :)
1 Solution
Split the filename with the path into an array using string.Split function and "\" as delimiter.
Use the regular expression on the last cell in the array to check if it consist of the word "file".
Corey_819Author Commented:
Thanks bennyshohman, I was making this way more complicated then it needed to be. Thanks for your help that worked. ;:)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now