473,409 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

UrlEncode and character "*"

To ensure a filename (entered by a user) does not contain any special
characters, I use the "UrlEncode" method:
string FileName = System.Web.HttpUtility.UrlEncode(textBox.Text);

Unfortunately, the character "*" is not encoded so I have an error
writing on disk if the filename contains a "*".

Is there another C# method that handles all special characters,
including the "*" ?
Anne

Nov 16 '05 #1
2 4897
You should look at using a regular expression validator to allow only the
submission of alpha chars? That way you wont have to worry about the
encoding. Also, if you cant do that then use replace to change any invalid
chars to underscores so you would have a valid filename.

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP
"Anne" <an*@cretei.com> wrote in message news:41**************@cretei.com...
To ensure a filename (entered by a user) does not contain any special
characters, I use the "UrlEncode" method:
string FileName = System.Web.HttpUtility.UrlEncode(textBox.Text);

Unfortunately, the character "*" is not encoded so I have an error
writing on disk if the filename contains a "*".

Is there another C# method that handles all special characters,
including the "*" ?
Anne

Nov 16 '05 #2
Hello,

I have this link for you:

http://www.experts-exchange.com/Prog..._21078423.html

HttpUtility.UrlEncode encodes an URL string so it is not misunderstood, and
is not used for the filesystem.

--
Regards,
Kristofer Gafvert
http://www.ilopia.com
"Anne" <an*@cretei.com> wrote in message news:41**************@cretei.com...
To ensure a filename (entered by a user) does not contain any special
characters, I use the "UrlEncode" method:
string FileName = System.Web.HttpUtility.UrlEncode(textBox.Text);

Unfortunately, the character "*" is not encoded so I have an error
writing on disk if the filename contains a "*".

Is there another C# method that handles all special characters,
including the "*" ?
Anne

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: farseer | last post by:
Hi, i have a file which contains data that is delimted by non-printable character "0x1f". how can i parse this file with that character as the delimiter?
1
by: joe | last post by:
I need to replace some question marks in a number of records, but the find/replace tool uses that character as a wildcard. How can I search and replace question marks? Thanks in advance.
0
by: muesliflakes | last post by:
I have tried to build an Installation Project for to different applications. Both are simple. Steps Taken: * Add New Setup Project to the solution * Set the project out to the application...
6
by: Lucvdv | last post by:
In a sorted list, certain characters are grouped together, for example "çb" (cedille b) comes after "ca" but before "cc". Is there a built-in way to find out what 'base character', such as C for...
2
by: Kannan | last post by:
In section 7.19.6.1 on ISO C specification, it says about a format character "space". When and how we will use this "space" format? I mean is there a usage, for e.g. like printf("%space",...); ? ...
1
by: Kris | last post by:
Hi.. Why is it impossible to add a "&" character to item in VS2005 menustrip? In properties, it preserves itself as "&", but in menu, shows up as some small line instead of &. Can you help?
5
by: Nicolas Pontoizeau | last post by:
Hi, I am handling a mixed languages text file encoded in UTF-8. Theres is mainly French, English and Asian languages. I need to detect every asian characters in order to enclose it by a special...
2
by: Diilb | last post by:
I am using DOM to create an rss feed. The problem I am running into is "special characters" such as é è ç. If I try adding them to the XML as character data (CData), DOM chokes and throws out...
5
by: rellaboyina | last post by:
Dear All, I am facing a problem in escaping the character "#" from the url. I am working in Mason framework now which uses Perl, HTML and Javascript. What I really want is to escape the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.