Solved

Using Regular Expression to Validate File in the FileUpload Control

Posted on 2007-03-22
2
221 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
ID: 18771669
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
ID: 18771832
Thanks bennyshohman, I was making this way more complicated then it needed to be. Thanks for your help that worked. ;:)
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Error on link 14 48
how can i get the executable application's path in a specific form? ('\\' instead of '\ ') 5 40
Graphics 2 30
.NET 2008 VB and C# 6 28
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

832 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