[Checksession]
Public ActionResult Expdatatwo ()
{
Try
{
String status_missionn = request.querystring["Sexch"];
Paradoxwebservice.paradoxserviceclient client = new Paradoxwebservice.paradoxserviceclient ();
Exportresultinfo res = client. Exportparadoxdatabase (Loadexportsqlstrtwo (Status_missionn), "GLJ");
String xmldirectory = System.Web.Hosting.HostingEnvironment.MapPath ("~/app_data/download/");
String fileName = session["Hangji"]. ToString () + session["Atmtwo_code"]. ToString () + DateTime.Now.ToString ("Yyyymmddmmss") + ". DB "; The file name is in seconds.
# Region processing garbled
Encoding Encoding;
string outputfilename = null;
String browser = Request.UserAgent.ToUpper ();
if (browser. Contains ("MS") = = True && browser. Contains ("IE") = = True)
{
outputfilename = Httputility.urlencode (FileName, Encoding.UTF8). Replace ("+", "%20");
encoding = System.Text.Encoding.Default;
}
else if (browser. Contains ("FIREFOX") = = True)
{
outputfilename = fileName;
encoding = System.Text.Encoding.GetEncoding ("GB2312");
}
Else
{
outputfilename = Httputility.urlencode (fileName);
encoding = System.Text.Encoding.Default;
}
#endregion
String url = xmldirectory + fileName;
Converttodb (Res. Exportdbbuffer, URL);
Return File (URL, "Application/vnd.borland", outputfilename);
}
catch (Exception ex)
{
throw new Exception (ex. Message);
}
}
<summary>
bytes into a file.
</summary>
<param name= "Buffer" ></param>
private void Converttodb (byte[] buffer, string filePath)
{
FileStream fstream = System.IO.File.Create (filePath, buffer. Length);
Try
{
FStream. Write (buffer, 0, buffer. Length);
}
catch (Exception ex)
{
}
Finally
{
FStream. Close ();
}
}
In ASP. NET, ie and Firefox download file with Chinese character name garbled solution