473,796 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Http Utility.UrlEnco de(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 4913
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.c om...
To ensure a filename (entered by a user) does not contain any special
characters, I use the "UrlEncode" method:
string FileName = System.Web.Http Utility.UrlEnco de(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.Url Encode 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.c om...
To ensure a filename (entered by a user) does not contain any special
characters, I use the "UrlEncode" method:
string FileName = System.Web.Http Utility.UrlEnco de(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
4888
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
10078
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
1792
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 project (Active) * Build Installation Project When I try to run the setup.msi, a MessageBox comes up saying "The
6
1809
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 cedille, a character belongs to for a given globalization setting?
2
3793
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",...); ? Thanks, Kannan
1
1629
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
4088
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 tag for latex. Does anybody know if there is a unicode "table of character" implementation in python? I mean, I give a character and python replys me with the language in which the character occurs. Thanks in advance
2
5584
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 errors. If I do a search and replace on the characters changing them to HTML entities instead of using CDATA, DOM chokes up again. If I do a combination of both (search and replace then add as Character Data) it does not choke, but the RSS...
5
1723
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 character "#" from the value assigned to a variable. As this value gets appended to the url, I am not getting the correct and expected values. Eg: Suppose $value = "My#Group"; Here I want to escape the character # so that the variable $value contains...
0
9680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9528
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10456
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10174
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7548
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2926
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.