Hi,
I am working on web application. As part of that, I uploaded pdf files into database and file names are like english (eg: abcd.pdf) and swedish (eg: sÖävi.pdf).
All files are saving as i wish.
the issue is, while retrieving the pdf., it is opening dialog box like below, their title of the file name holding swedish characters are turning to special characters.(and english names are showing proper)
But i don’t want special characters i want the title of the file name should be same how i saved into database.
Dialog box:
"Do you want to open or save sÖävi.pdf " (here Öä are swedish characters, in the place of Öä it is showing special characters).0
Please help me out with this issue
protected void DownloadFile(object sender, EventArgs e)
{
int id = int.Parse((sender as LinkButton).CommandArgument);
byte[] bytes;
string fileName, contentType;
string constr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "select vcrName, intSize, binPDFdata, ContentType from savepdf where intId=@Id"; //@Id :here we r just declaring varaible.. down statement we passed values for this ..from link button grid view :id
cmd.Parameters.AddWithValue("@Id", id); // it came from :::int id = int.Parse((sender as LinkButton).CommandArgument);
cmd.Connection = con;
con.Open();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
sdr.Read();
bytes = (byte[])sdr["binPDFdata"];
contentType = sdr["ContentType"].ToString();
fileName = sdr["vcrName"].ToString();
}
con.Close();
}
}
Response.Clear();
Response.Buffer = true;
Response.Charset = "";
Response.ClearContent();
Response.ClearHeaders();
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = contentType;
Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();
}