protected void btnDownload_Click(object sender, EventArgs e) { string[] file = hdfile.Value.Split('|'); string fileName = file[0]; string filePath = Server.MapPath(ConfigurationManager.AppSettings["FolderPath"] + file[1]); if (System.IO.File.Exists(filePath)) { Model.File_Dowm_Detail fdd = new Model.File_Dowm_Detail(); fdd.dowm_person = Convert.ToInt32((Session["login"] as Model.BaseUser).UserID); fdd.dowm_date = DateTime.Now; fdd.file_id = int.Parse(file[2]); new BLL.File_Dowm_Detail().Add(fdd); FileStream fs = new FileStream(filePath, FileMode.Open); byte[] bytes = new byte[(int)fs.Length]; fs.Read(bytes, 0, bytes.Length); fs.Close(); Response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); Response.BinaryWrite(bytes); Response.Flush(); Response.End(); Response.Clear(); Response.Close(); } else { ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>showmsg();</script>"); } }
protected void Button2_Click(object sender, EventArgs e) { try { string fid = hdfid.Value; Model.File_Dowm_Detail fdd = new Model.File_Dowm_Detail(); fdd.dowm_person = Convert.ToInt32((Session["login"] as Model.BaseUser).UserID); fdd.dowm_date = DateTime.Now; fdd.file_id = int.Parse(fid); new BLL.File_Dowm_Detail().Add(fdd); } catch { } }
private string FileDownloadCount(HttpContext context) { try { string fid = context.Request["fid"].Trim(); Model.File_Dowm_Detail fdd = new Model.File_Dowm_Detail(); fdd.dowm_person = Convert.ToInt32((context.Session["login"] as Model.BaseUser).UserID); fdd.dowm_date = DateTime.Now; fdd.file_id = int.Parse(fid); new BLL.File_Dowm_Detail().Add(fdd); return("1"); } catch { return("0"); } }
protected void Button2_Click(object sender, EventArgs e) { try { //string fid = hdfid.Value; string[] file = hdfile.Value.Split('|'); Model.File_Dowm_Detail fdd = new Model.File_Dowm_Detail(); fdd.dowm_person = Convert.ToInt32((Session["login"] as Model.BaseUser).UserID); fdd.dowm_date = DateTime.Now; fdd.file_id = int.Parse(file[2]); new BLL.File_Dowm_Detail().Add(fdd); //Response.Write("<script>var nw = window.open('/FileUpload" + file[1] + "', 'big', 'top=0, left=0, toolbar=no, menubar=yes, scrollbars=yes, resizable=yes,location=no, status=no,channelmode = yes');try {nw.document.title = '预览';} catch (e) {}</script>"); ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>openViewShow('/FileUpload" + file[1] + "');</script>"); } catch { } }