For Programmers: Free Programming Magazines  


Home > Archive > C# > July 2005 > Matching file names









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Matching file names
no_spam_please

2005-07-27, 9:03 am

Hi,

I was looking to figure out if .Net had a built in class for matching
files extensions. For example, the user will specify the accepted file
extensions as follow: "*.pdf;*.doc;*.wp". My code needs to verify that
the file format meets the criteria.

How can I do this? Thank you....

Bruce Wood

2005-07-28, 5:02 pm

I wrote a small utility method that changed traditional file patterns
into Regex regular expressions. For example:

*.pdf becomes .*\.pdf

Allowing several file extensions can also be expressed in Regex. Once
you've translated the file pattern into a regular expression, just use
the Regex classes to match it against user input, or whatever.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com