/**/ /// <summary> /// 文件列表中下载文件按钮单击事件响应 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void uwg_UpFiles_ClickCellButton( object sender, Infragistics.WebUI.UltraWebGrid.CellEventArgs e) ... { try ...{ //获取当前文件ID int upFileID = Convert.ToInt32(e.Cell.Row.Cells[0].Value); //获取当前文件对象 using (TrainContentUpFile tcuf = new TrainContentUpFile(upFileID)) ...{ byte[] MyString = tcuf.UpFileData; if (MyString.Length == 0) return; int myLength = MyString.Length; string myUrl = HttpContext.Current.Server.MapPath(this.Request.ApplicationPath) + @"TempDownLoad" + tcuf.UpFileName; FileStream fs = new FileStream(myUrl, FileMode.OpenOrCreate); BinaryWriter w = new BinaryWriter(fs); w.BaseStream.Write(MyString, 0, myLength); w.Flush(); w.Close(); Response.Redirect(Context.Request.ApplicationPath + "/TempDownLoad/" + tcuf.UpFileName); fs.Flush(); fs.Close(); } } catch (System.Exception ex) ...{ SafeCommonSetting.ProcessExeception(this, ex, "下载文件失败!"); } }