473,387 Members | 1,515 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,387 software developers and data experts.

File download and spanish characters like "ñ"

Hi!

I have this C# code in a Button_Click event procedure:

string FilePath = MapPath("diseño.doc");
Response.ContentType = "Application/msword";
Response.AppendHeader("content-disposition", "attachment;filename=" +
"diseño.doc");
Response.WriteFile(FilePath);
Response.Flush();
Response.End();

The file name ("diseño.doc") contains the spanish character "ñ"
[ALT][164]
When the button is clicked, the download dialog box appears, but the
name of the file is shown as "diseño.doc".

The file is successfully downloaded to the client machine, but it
seems like Response.AppendHeader doesn't support other non-us
characters like "ñ","á", "é", "í", etc., so these characters are
changed for characters like these: ñ ño

Does anybody know how to solve this problem?

I would appreciate any help!!!
Thank you!
Nov 18 '05 #1
4 2442
Can you URLEncode/HTMLEncode the filename? That should turn it into
something like dise%164;no.doc (except it'd be hexidecimal).

I don't know about browser compatibility on that one.

cc******@gmx.net (Carolina) wrote in news:f464b802.0410130915.5efd5a76
@posting.google.com:
Hi!

I have this C# code in a Button_Click event procedure:

string FilePath = MapPath("diseño.doc");
Response.ContentType = "Application/msword";
Response.AppendHeader("content-disposition", "attachment;filename=" +
"diseño.doc");
Response.WriteFile(FilePath);
Response.Flush();
Response.End();

The file name ("diseño.doc") contains the spanish character "ñ"
[ALT][164]
When the button is clicked, the download dialog box appears, but the
name of the file is shown as "diseño.doc".

The file is successfully downloaded to the client machine, but it
seems like Response.AppendHeader doesn't support other non-us
characters like "ñ","á", "é", "í", etc., so these characters are
changed for characters like these: ñ ño

Does anybody know how to solve this problem?

I would appreciate any help!!!
Thank you!


Nov 18 '05 #2
Thank you for your help!

I made this change and it works:

Response.AppendHeader("content-disposition", "attachment;filename=" +
Server.UrlEncode("diseño.doc").Replace("+","%20")) ;
Nov 18 '05 #3
HTMLEncode converts spaces to %20 and URLEncode converts spaces to +. You
kind of have a combination going on there. No problem as long as it works.
cc******@gmx.net (Carolina) wrote in news:f464b802.0410141239.6e9c3b5
@posting.google.com:
Thank you for your help!

I made this change and it works:

Response.AppendHeader("content-disposition", "attachment;filename=" +
Server.UrlEncode("diseño.doc").Replace("+","%20")) ;


Nov 18 '05 #4
I have ever been found this problem too and I fix the problem with filename
like your suggestion but it still have other problem that is if you click
"open" when the download dialog box is pop up the filename will not decode to
the original but if you click "save" every thing is find.

Could anyone please help me to solve the problem when click "open"?
Thanks.

Nov 18 '05 #5

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

Similar topics

10
by: mike | last post by:
regards: I use Jtidy (api) to translate a HTML file into a "XHTML file". But The "XHTML file" cannot be identified by nokia 6600. Do I miss something important? Or this is Jtidy's weakness or...
1
by: Luis Ferrao | last post by:
Hi, My Windows Forms application uses the WebBrowser control to open an Excel file since OLE objects are gone in .Net. The application is actualy a clone of the one found in the MS Knowledge...
24
by: AES/newspost | last post by:
On many web sites or pages (including my own home page) clicking on certain links will start downloading a PDF file, sometimes without the author having provided any warning in the text of the page...
3
by: N. Graves | last post by:
Hello, I don't understand this error message." Error accessing File. Network Connection may have been lost." I'm not using any network connection for the database. In the VBA editor is goes...
4
by: wob | last post by:
Many thanks for those who responded to my question of "putting greek char into C string". In searching for an solution, I noticed that there are more than one version of "Extended ASCII...
3
by: charliewest | last post by:
I realize this most likely isn't the right newsgroup, but i'm having troube finding anyswers: I'm working with MS C# .NET 2003 Professional Edition on a machine that was set to regional...
5
by: Mr Gordonz | last post by:
Hi all, I want to put a button on a page, and when the user clicks it, the standard Windows "Open File" dialogue box opens, and the user can browse/select a file on their PC. Having selected a...
0
by: yma | last post by:
Hi, I have a web.config file that contains <httpHandlers> section that causes "cannot load file..." error. If I delete this section, it is OK. Why did vb.net add this section? It does not add...
4
by: L. Scott M. | last post by:
I am invoking a file download using the following code: Response.Clear(); Response.AddHeader("Content-Disposition", "attachment; filename=" + downloadFile.Name);...
2
by: nedu | last post by:
Hi, Since I need to insert a a excel file in the HTML, I used <iframe> tag. But this tag PROMPT me the "File Download" dialog box every time the page got refreshed. Is there any ASP code to block...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
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...

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.