/// <summary> /// 下载文件 /// </summary> /// <param name="name"></param> /// <returns></returns> public FileResult Download(string name) { string path = Maincontrol.GetFullPath(name); string contentType = MimeMapping.GetMimeMapping(path); return(File(path, contentType, name)); }
/// <summary> /// 重命名 /// </summary> /// <returns></returns> public JsonResult NewName() { string name = Request["name"].ToString(); if (name.Contains(".")) { int idxStart = name.LastIndexOf("."); string newname = Request["newname"].ToString() + name.Substring(idxStart, name.Length - idxStart); if (Maincontrol.NewNameFloderOrFile(Maincontrol.GetFullPath(name), newname)) { return(Json(true)); } else { return(Json(false)); } } else { string newname = Request["newname"].ToString(); if (Maincontrol.NewNameFloderOrFile(Maincontrol.GetFullPath(name), newname)) { return(Json(true)); } else { return(Json(false)); } } }
/// <summary> /// 解压文件名 /// </summary> /// <returns></returns> public JsonResult UnRAR() { string name = Request["name"].ToString(); string newname = Request["newname"].ToString(); if (RarHelper.UnRAR(Maincontrol.GetFullPath(name), Maincontrol.GetFullPath(newname) + @"\" + name.Split('.')[0])) { Maincontrol.NewFloder(name.Split('.')[0], Maincontrol.GetID(newname), Maincontrol.GetRelativePath(newname) + @"\" + name.Split('.')[0]); Filetransfer.FindFile(new DirectoryInfo(Maincontrol.GetFullPath(newname) + @"\" + name.Split('.')[0])); return(Json(true)); } else { return(Json(false)); } }
/// <summary> /// 下载文件 /// </summary> /// <param name="name"></param> /// <returns></returns> public FileResult Download(string name) { Filetransfer.DeleteFolder(Server.MapPath("~/Zip/")); if (name.Contains(".")) { string path = Maincontrol.GetFullPath(name); string contentType = MimeMapping.GetMimeMapping(path); return(File(path, contentType, name)); } else { if (Filetransfer.ZipFile(Server.MapPath("~/NetworkDisk/" + name), Server.MapPath("~/Zip/" + name + ".zip"))) { string contentType = MimeMapping.GetMimeMapping(Server.MapPath("~/Zip/" + name + ".zip")); return(File(Server.MapPath("~/Zip/" + name + ".zip"), contentType)); } return(null); } }
/// <summary> /// 删除文件 /// </summary> /// <returns></returns> public ActionResult Delete() { string name = Request["name"].ToString(); if (Filetransfer.Deletefile(Maincontrol.GetFullPath(name))) { if (Maincontrol.DeleteFloderOrFile(name)) { return(Json(true)); } else { return(Json(false)); } } else { return(Json(false)); } }
/// <summary> /// 新建文件夹 /// </summary> /// <returns></returns> public JsonResult NewFile() { if (Request["path"].ToString() != "false") { if (Filetransfer.NewDirectory(Maincontrol.GetFullPath(Request["path"].ToString()) + @"\" + Request["newfile"].ToString())) { if (Maincontrol.NewFloder(Request["newfile"].ToString(), Maincontrol.GetID(Request["path"].ToString()), Maincontrol.GetRelativePath(Request["path"].ToString()) + @"\" + Request["newfile"].ToString())) { return(Json(true)); } else { return(Json(false)); } } else { return(Json(false)); } } else { string name = Request["newfile"].ToString(); string path = Server.MapPath("~/NetworkDisk/"); if (Filetransfer.NewDirectory(path + name)) { if (Maincontrol.NewFloder(name, 1, @"NetworkDisk\" + name)) { return(Json(true)); } else { return(Json(false)); } } else { return(Json(false)); } } }
/// <summary> /// 复制文件 /// </summary> /// <returns></returns> public JsonResult Copy() { string name = Request["name"].ToString(); string newname = Request["newname"].ToString(); if (Filetransfer.Copyfile(Maincontrol.GetFullPath(name), Maincontrol.GetFullPath(newname) + @"\" + Maincontrol.GetMd5Name(name))) { if (Maincontrol.CopyFile(name, Maincontrol.GetFullPath(newname))) { return(Json(true)); } else { return(Json(false)); } } else { return(Json(false)); } }
/// <summary> /// 分享文件 /// </summary> /// <returns></returns> public JsonResult Share() { string name = Request["name"].ToString(); if (name.Contains(".")) { if (Maincontrol.ShareFileOrFolder(Maincontrol.GetID(name), Convert.ToInt32(Request["type"].ToString()), Maincontrol.GetFullPath(name), Request["code"].ToString(), Convert.ToDouble(Request["time"].ToString()))) { return(Json(Request["host"].ToString() + "/" + urlconvertor(Maincontrol.GetRelativePath(name)))); } return(null); } else { if (Filetransfer.ZipFile(Maincontrol.GetFullPath(name), Maincontrol.GetFullPath(name) + ".zip")) { if (Maincontrol.ShareFileOrFolder(Maincontrol.GetID(name), Convert.ToInt32(Request["type"].ToString()), Maincontrol.GetFullPath(name) + ".zip", Request["code"].ToString(), Convert.ToDouble(Request["time"].ToString()))) { return(Json(Request["host"].ToString() + "/" + urlconvertor(Maincontrol.GetRelativePath(name) + ".zip"))); } } return(null); } }