?
Solved

How to determine no special characters are in filename

Posted on 2009-02-09
5
Medium Priority
?
1,229 Views
Last Modified: 2012-05-06
I have a .NET form that allows users to upload their text files. I don't want to allow files containing any special characters to be uploaded.

I only want characters.doc
or characters.docx
and so on.
<input id="DocFile" type="file" runat="server" title="upldFileBox" />
This is what is seen if I try to use a regular expression validator:
C:\Documents and Settings\syount\Desktop\test.docx
C:\Documents and Settings\syount\Desktop\test.doc
C:\Documents and Settings\syount\Desktop\test.txt
and so on.
 
string filename = Path.GetFileName(DocFile.Value);
But this is what is seen in the code behind:
text.doc
test.docx
and so on.

Open in new window

0
Comment
Question by:net_susan
  • 4
5 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 23595058
0
 
LVL 1

Author Comment

by:net_susan
ID: 23595312
I'm going to try this, but I'd like to do it on the client side if possible.
0
 
LVL 1

Author Comment

by:net_susan
ID: 23599634
I guess I'm just not figuring out how to plug this into what I have.
0
 
LVL 1

Author Comment

by:net_susan
ID: 23606005
I just want to look at the string filename and determine if there are any special characters in it (besides the one . before the extension name).
0
 
LVL 1

Accepted Solution

by:
net_susan earned 0 total points
ID: 23842758
I couldn't get enough help with the answer I was looking for, so I just made forced something else to be the filename (eliminating special characters).
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

850 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