Solved

Using Regular Expression to Validate File in the FileUpload Control

Posted on 2007-03-22
2
217 Views
Last Modified: 2010-04-16
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 :)
0
Comment
Question by:Corey_819
2 Comments
 
LVL 1

Accepted Solution

by:
bennyshoham earned 100 total points
Comment Utility
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".
0
 
LVL 1

Author Comment

by:Corey_819
Comment Utility
Thanks bennyshohman, I was making this way more complicated then it needed to be. Thanks for your help that worked. ;:)
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now