protected void ObjectDataSourceItemsList_OnDeleting(object sender, ObjectDataSourceMethodEventArgs e) { string path = WebConfigurationManager.AppSettings["DownloadFilesPath"]; DownloadFile d = e.InputParameters[0] as DownloadFile; DownloadFiles ds = new DownloadFiles(); DownloadFile f = d != null? ds.GetById(d.ID) : d ; if (!string.IsNullOrEmpty(path) && !string.IsNullOrEmpty(f.FileName) && f != null && d != null) { string rootpath = Path.Combine(path, f.FileName); if (File.Exists(rootpath)) { File.Delete(rootpath); } rootpath = Path.Combine(path, d.ID + ".jpg"); if (File.Exists(rootpath)) { File.Delete(rootpath); } } }
protected void GridViewItemsList_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Download") { int id = int.Parse(e.CommandArgument.ToString()); DownloadUserForms duf = new DownloadUserForms(); List<DownloadUserForm> list = duf.GetByFileID(id); DownloadFiles df = new DownloadFiles(); var file = df.GetById(id); ReportOptions ro = new ReportOptions(); ro.Columns = "Email,FirstName,LastName"; ro.HeaderText = "Email,Имя,Фамилия"; ro.FileName = string.Format("csvreport_{0}_file.csv",file.FileName); new CsvHelper().WriteToCSV(list, ro); } }