User1389397289 posted
I believe I got the solution of your problem.
For reproducing your problem I made a temp. xlsx file on my localhost with using Hebrew characters(כשא.xlsx).And used the following code for saving the Hebrew characters file.
I am getting the correct name for saving the file as file name is not converted to the Gibberish characters.
The key line of the code is getting the file name as below:
string filename = fileInfo.Name;
filename = HttpUtility.UrlPathEncode(filename);
Code:
Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1255");
//for Hebrew
Response.HeaderEncoding = System.Text.Encoding.GetEncoding("windows-1255");
//for Hebrew
string filepath = fileUpload.PostedFile.FileName.ToString();
System.IO.FileInfo fileInfo = new System.IO.FileInfo(filepath);
string filename = fileInfo.Name;
filename = HttpUtility.UrlPathEncode(filename);
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" +
filename);
Response.AppendHeader("Content-Length", fileInfo.Length.ToString());
//Sends only the File with no Extra bytes
Response.Flush();
Response.WriteFile(filepath);
Response.Flush(); //Release the file so it can be Deleted
Please Mark As Answer if It works for you
Regards,
MKhare