protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { Response.WriteFile("TextFile.txt"); } protected void Button2_Click(object sender, EventArgs e) { string path = Server.MapPath("~/字符串专题.doc");//文件的路径 System.IO.FileInfo file = new System.IO.FileInfo(path); Response.Clear (); the Response.Charset = " UTF-. 8 " ; // encoded output provided Response.ContentEncoding = System.Text.Encoding.UTF8; // add header information, is "file download / Save As" dialog specifies the default file name Response.AddHeader ( " Content-Disposition " , " Attachment; filename = " + Server.UrlEncode (file.name)); // add header information, specify the file size, so that the browser can display the download progress Response. the AddHeader ( " the Content-the Length " , file.Length.ToString ()); // the specified stream is returned to a client can not be read, must be downloaded Response.ContentType = " file application / MSWord " ; // the file stream to the client Response.WriteFile (file.FullName); Response.End (); // Response.WriteFile ( "Test.doc"); } can also be used the method of opening the file directly following: ScriptManager.RegisterStartupScript (Page, Page.GetType (), "" , " the window.open ( ' " + string_FileRelativePath + " ', '_blank'); " , to true );