public Response GetFile(dynamic _) { var fileId = this.GetReqData().ToJObject()["fileId"].ToString(); var data = annexesFileIbll.GetEntity(fileId); if (data != null) { var fileType = data.F_FileType; var filesType = Config.GetValue("ImageTypes").ToLower(); var filePath = data.F_FilePath; if (filesType.Contains(fileType)) { if (FileDownHelper.FileExists(filePath)) { var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read); if (fileType == "jpg" || fileType == "jpeg") { fileType = "jpeg"; } return(Response.FromStream(stream, @"image/" + filesType)); } } } return(Fail("资源不存在")); }
public void DownloadFile(string keyValue, string filename, string recId) { if (string.IsNullOrEmpty(keyValue)) { return; } FileInfoEntity data = null; if (!string.IsNullOrEmpty(filename)) { data = fileInfoBLL.GetEntity(recId, Server.UrlDecode(filename)); } else { data = fileInfoBLL.GetEntity(keyValue); } if (data != null) { string name = string.IsNullOrEmpty(filename) ? Server.UrlDecode(data.FileName) : Server.UrlDecode(filename);//返回客户端文件名称 string filepath = this.Server.MapPath(data.FilePath); if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, name); } else { Response.StatusCode = 404; Response.Redirect("../../Error/ErrorPath404", true); return; } } }
/// <summary> /// 下载 /// </summary> /// <param name="keyValue"></param> /// <param name="filename"></param> /// <param name="recId"></param> public void DownloadFile(string keyValue, string filename, string recId) { var fileFolderBLL = new FileFolderBLL(); var fileInfoBLL = new FileInfoBLL(); if (string.IsNullOrEmpty(keyValue)) { return; } FileInfoEntity data = null; if (!string.IsNullOrEmpty(filename)) { data = fileInfoBLL.GetEntity(recId, Server.UrlDecode(filename)); } else { data = fileInfoBLL.GetEntity(keyValue); } if (data != null) { string name = string.IsNullOrEmpty(filename) ? Server.UrlDecode(data.FileName) : Server.UrlDecode(filename);//返回客户端文件名称 string filepath = this.Server.MapPath(data.FilePath); if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, name); } } }
public void DownLoadEmailFiles(string keyvalue, string type) { var data = new EmailApp().Email_Path(keyvalue); string filename = ""; string filepath = ""; if (type == ".zip") { //文件名 filename = Server.UrlDecode(data.PF_Src.Substring(data.PF_Src.LastIndexOf("/") + 1)); //路径 filepath = Server.MapPath(data.PF_Src); } else { filename = Server.UrlDecode(type); filepath = Server.MapPath(data.PF_Src.Replace(data.PF_Src.Substring(data.PF_Src.LastIndexOf("/")), "") + "/" + filename); } filepath = filepath.Replace("\\Email\\DownLoadEmailFiles", ""); // return File(new System.IO.FileStream(filepath, System.IO.FileMode.Open), "application/octet-stream", filename); if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, filename); } }
public void DownloadFile(string keyValue) { string filename = Server.UrlDecode("客户导入模板.xls");//返回客户端文件名称 string filepath = this.Server.MapPath("~/Resource/ExcelTemplate/客户导入模板.xls"); if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, filename); } }
public void DownloadBackup(string keyValue) { var data = DbBackupApp.GetForm(keyValue); string filename = System.Web.HttpUtility.UrlDecode(data.FileName); string filepath = FileHelper.MapPath(data.FilePath); if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, filename); } }
public ActionResult GetUeditorImg(string id) { string path = Config.GetValue("imgPath") + "/ueditor/upload/image" + id; path = System.Text.RegularExpressions.Regex.Replace(path, @"\s", ""); if (FileDownHelper.FileExists(path)) { FileDownHelper.DownLoadold(path, id.Split('/')[2]); } return(Success("获取成功")); }
public void DownloadBackup(string keyValue) { var data = dbBackupApp.GetForm(keyValue); string filename = Server.UrlDecode(data.F_FileName); string filepath = Server.MapPath(data.F_FilePath); if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, filename); } }
public void DownloadFile(string keyValue) { var data = fileInfoBLL.GetEntity(keyValue); string filename = Server.UrlDecode(data.F_FileName);//返回客户端文件名称 string filepath = this.Server.MapPath(data.F_FilePath); if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, filename); } }
/// <summary> /// 文件下载 /// </summary> /// <param name="KeyValue">主键</param> /// <returns></returns> public void Download(string KeyValue) { Base_NetworkFile entity = base_networkfilebll.Repository().FindEntity(KeyValue); string filename = Server.UrlDecode(entity.FileName); //返回客户端文件名称 string filepath = Server.UrlDecode(entity.FilePath); //文件虚拟路径 if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, filename); } }
public void DownAnnexesFile(string fileId) { var data = annexesFileIBLL.GetEntity(fileId); string filename = Server.UrlDecode(data.F_FileName);//返回客户端文件名称 string filepath = data.F_FilePath; if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, filename); } }
public void FileDownload(string file) { var data = JObject.Parse(Uri.UnescapeDataString(file)); string filename = data["originalName"].ToString();//返回客户端文件名称 string filepath = this.Server.MapPath(data["path"].ToString()); if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, filename); } //return Content("下载成功"); }
/// <summary> /// 下载文件 /// </summary> /// <param name="_"></param> /// <returns></returns> public Response DownAnnexesFile(dynamic _) { string name = this.GetReqData(); string fileId = name.Split('.')[0]; var data = annexesFileIBLL.GetEntity(fileId); string filepath = data.F_FilePath; if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadnew(filepath); } return(Success("")); }
public void DownLoadBackups(string id) { B_Backups b_backup = new B_Backups(); var data = b_backup.Get(Convert.ToInt32(id)); string filename = Server.UrlDecode(data.fileName); string filepath = Server.MapPath(data.filePath); if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, filename); } }
public void DownloadBackup(string keyValue) { if ((keyValue != "undefined") && !string.IsNullOrEmpty(keyValue)) { var data = dbBackupApp.GetForm(keyValue); string filename = Server.UrlDecode(data.F_FileName); string filepath = data.F_FilePath; if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, filename); } base.OperateLog("据库备份下载", "/SystemSecurity/DbBackup/DownloadBackup", "备份下载", Application.DbLogType.Other); } }
/// <summary> /// 下载文件 /// </summary> /// <param name="pathList">文件路径集合(相对路径)</param> /// <returns></returns> public void DownloadFile(string pathList) { if (!string.IsNullOrEmpty(pathList)) { List <string> lstid = pathList.Split(',').ToList <string>(); if (lstid.Count == 1) { var absolutePath = Server.MapPath(lstid[0]);//转成绝对路径 var fullName = System.IO.Path.GetFileName(absolutePath); if (System.IO.File.Exists(absolutePath)) { FileDownHelper.DownLoadold(absolutePath, fullName); return; } } else if (lstid.Count == 0) { return; } //将文件拷贝至指定临时路径并压缩打包 string newFilename = DateTime.Now.ToString("yyyyMMddHHmmss"); string newFolder = "/Temp/" + newFilename + "/"; string newZip = Server.MapPath("/Temp/" + newFilename + ".zip"); //压缩包 FileHelper.CreateDirectory(Server.MapPath(newFolder)); //创建一个临时文件夹 for (int i = 0; i < lstid.Count; i++) { var filepath = Server.MapPath(lstid[i]); var fullName = System.IO.Path.GetFileName(filepath); if (FileDownHelper.FileExists(filepath)) { FileHelper.Copy(filepath, Server.MapPath(newFolder + fullName));//将文件拷贝到临时文件夹 } } //将文件夹进行GZip压缩 ZipFloClass Zc = new ZipFloClass(); Zc.ZipFile(Server.MapPath(newFolder), newZip);//生成压缩包 if (FileDownHelper.FileExists(newZip)) { FileDownHelper.DownLoadold(newZip, newFilename + ".zip");//下载压缩包 } //删除文件夹 FileHelper.DeleteDirectory(newFolder); //删除文件夹 FileHelper.DeleteFile(newZip); //删除临时压缩包 } return; }
public void DownloadTemplate(string keyValue) { try { string filename = Server.UrlDecode(keyValue); string filepath = Path.Combine(Server.MapPath("/Uploads/Template/"), keyValue); if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, filename); } } catch (Exception ex) { throw; } }
/// <summary> /// 下载文件 /// </summary> /// <param name="keyValue">主键</param> /// <returns></returns> //[HttpPost] //[HttpGet] //[HandlerAuthorize(PermissionMode.Ignore)] public void DownloadFile(string keyValue, string filename, string recId) { if (string.IsNullOrEmpty(keyValue)) { return; } FileInfoEntity data = null; if (!string.IsNullOrEmpty(filename)) { data = fileInfoBLL.GetEntity(recId, Server.UrlDecode(filename)); } else { data = fileInfoBLL.GetEntity(keyValue); } if (data != null) { string name = string.IsNullOrEmpty(filename) ? Server.UrlDecode(data.FileName) : Server.UrlDecode(filename);//返回客户端文件名称 string filepath = this.Server.MapPath(data.FilePath); if (name.ToLower().Contains(".gw")) { name = name.ToLower().Replace(".gw", ".pdf"); } if (filepath.ToUpper().LastIndexOf(".GW") > 0) { filepath = filepath.ToUpper().Replace(".GW", ".pdf"); } if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, name); } else { if (this.Server.MapPath(data.FilePath).ToUpper().LastIndexOf(".GW") > 0) { HttpContext.Response.Write("GW文件未找到或正在转换成PDF文件"); } else { HttpContext.Response.Write("文件未找到"); } } } }
public void DownloadProposal(string keyValue) { try { string filename = Server.UrlDecode(keyValue); string filepath = Path.Combine(Server.MapPath("/Uploads/Proposal/"), keyValue); if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, filename); } } catch (Exception ex) { new ErrorLogApp().SubmitForm(ex); throw; } }
public void DownAnnexesFileNew(string fileId) { var data = annexesFileIBLL.GetEntity(fileId); string filename = Server.UrlDecode(data.F_FileName);//返回客户端文件名称 string filepath = data.F_FilePath; var redPrintPath = data.F_FilePath.Replace(data.F_FileExtensions, "") + "_s" + data.F_FileExtensions; if (FileDownHelper.FileExists(redPrintPath)) { FileDownHelper.DownLoadold(redPrintPath, filename); } else { if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, filename); } } }
public void DownloadBackup(string keyValue) { if (!string.IsNullOrEmpty(keyValue)) { List <string> lstid = StringHelper.GetStrArray(keyValue, ',', false); if (lstid.Count == 1) { var data = pictureApp.GetForm(lstid[0]); //将压缩包下载 FileDownHelper.DownLoadold(Server.MapPath(data.F_FilePath), data.F_FullName);//单个图片直接下载 return; } //将图片拷贝至指定临时路径并压缩打包 string newFilename = DateTime.Now.ToString("yyyyMMddHHmmss"); string newFolder = "/Temp/" + newFilename + "/"; string newZip = Server.MapPath("/Temp/" + newFilename + ".zip"); //压缩包 FileHelper.CreateDirectory(Server.MapPath(newFolder)); //创建一个临时文件夹 for (int i = 0; i < lstid.Count; i++) { var data = pictureApp.GetForm(lstid[i]); string filename = Server.UrlDecode(data.F_FullName); string filepath = Server.MapPath(data.F_FilePath); if (FileDownHelper.FileExists(filepath)) { FileHelper.Copy(filepath, Server.MapPath(newFolder + data.F_FullName));//将文件拷贝到临时文件夹 } } //将文件夹进行GZip压缩 ZipFloClass Zc = new ZipFloClass(); Zc.ZipFile(Server.MapPath(newFolder), newZip);//生成压缩包 if (FileDownHelper.FileExists(newZip)) { FileDownHelper.DownLoadold(newZip, newFilename + ".zip");//下载压缩包 } //删除文件夹 FileHelper.DeleteDirectory(newFolder); //删除文件夹 FileHelper.DeleteFile(newZip); //删除临时压缩包 } }
public ActionResult ReadImage(string fileId) { var data = annexesFileIBLL.GetEntity(fileId); string filepath = data.F_FilePath; string filetype = data.F_FileType.ToLower(); var imgtypes = Config.GetValue("ImageTypes").ToLower();; if (imgtypes.Contains(filetype)) { if (FileDownHelper.FileExists(filepath)) { var stream = new FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.Read); if (filetype == "jpg" || filetype == "jpeg") { filetype = "jpeg"; } return(File(stream, @"image/" + filetype)); } } return(null); }
public JsonResult DelBackups(string ids) { Common.Json json = new Common.Json(); B_Backups b_backup = new B_Backups(); B_Manager b_mananger = new B_Manager(); foreach (var id in ids.Split(new char[] { ',' })) { var model = b_backup.Get(Convert.ToInt32(id)); string filepath = Server.MapPath(model.filePath); if (FileDownHelper.FileExists(filepath)) { FileHelper.DeleteFile(filepath); } model.delManager = b_mananger.Get(Convert.ToInt32(base.User.Identity.Name)); model.delTime = DateTime.Now; b_backup.Update(model); } json.msg = "成功删除" + ids.Split(new char[] { ',' }).Length + "个备份!"; return(Json(json)); }
public void DownloadFileForKeyValue(string keyValue) { FileInfoBLL fileInfoBLL = new FileInfoBLL(); if (string.IsNullOrEmpty(keyValue)) { return; } DataTable data = null; data = fileInfoBLL.GetFiles(keyValue); if (data != null && data.Rows.Count > 0) { string name = string.IsNullOrEmpty(data.Rows[0]["FileName"].ToString()) ? Server.UrlDecode(data.Rows[0]["FileName"].ToString()) : Server.UrlDecode(data.Rows[0]["FileName"].ToString());//返回客户端文件名称 string filepath = this.Server.MapPath(data.Rows[0]["FilePath"].ToString()); if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, name); } } }
public ActionResult ReadFirstImage(string folderId) { var imgtypes = Config.GetValue("ImageTypes").ToLower();; var fileList = annexesFileIBLL.GetList(folderId).Where(t => imgtypes.Contains(t.F_FileType.ToLower())); var data = fileList.FirstOrDefault(); if (data != null) { string filepath = data.F_FilePath; string filetype = data.F_FileType.ToLower(); if (FileDownHelper.FileExists(filepath)) { var stream = new FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.Read); if (filetype == "jpg" || filetype == "jpeg") { filetype = "jpeg"; } return(File(stream, @"image/" + filetype)); } } return(null); }