protected voidButton2_Click (Objectsender, EventArgs e) {
Can be added here to determine whether the loginstringFileName ="chracater14.jpg";//file name saved by client (supported by other file formats) stringFilePath = Server.MapPath (".. /.. /images/chracater14.jpg");//PathFileInfo FileInfo=NewFileInfo (FilePath); Response.Clear (); Response.clearcontent (); Response.ClearHeaders (); Response.AddHeader ("content-disposition","attachment;filename="+fileName); Response.AddHeader ("Content-length", fileInfo.Length.ToString ()); Response.AddHeader ("content-transfer-encoding","binary"); Response.ContentType="Application/octet-stream"; Response.ContentEncoding= System.Text.Encoding.GetEncoding ("gb2312"); Response.WriteFile (Fileinfo.fullname); Response.Flush (); Response.End (); }
How to log on in. NET to download a file Response.WriteFile implementation download