[WebMethod]//上传确认 public string UploadConfirm(string glytm, string isbn, string ztm, string cdxh) { try { Serv_UControl sc = Serv_UControl.getServUContorl(); return(sc.MoveFile(glytm, isbn, ztm, cdxh)); } catch { return("确认错误!"); } }
[WebMethod]//更改未确认文件 public bool UpdateUploadedFile(string glytm, string name, string newName, string ext) { try { Serv_UControl sc = Serv_UControl.getServUContorl(); string path = sc.GetFtpUserHomeDir(glytm).Replace("\r", "");//获取管理员目录 FileInfo file = new DirectoryInfo(path).GetFiles().ToList().First(f => f.Name == name + ext); file.MoveTo(path + "\\" + newName + ext); return(true); } catch { return(false); } }
[WebMethod]//移除未确认文件 public bool RemoveUploadedFile(string glytm, string name) { try { Serv_UControl sc = Serv_UControl.getServUContorl(); string path = sc.GetFtpUserHomeDir(glytm).Replace("\r", "");//获取管理员目录 FileInfo file = new DirectoryInfo(path).GetFiles().First(f => f.Name == name); file.Delete(); return(true); } catch { return(false); } }
[WebMethod]//文件长度 public string GetFile(string glytm, string isbn, string ztm, string cdxh) { List <FileInfo> listFile = new List <FileInfo>(); try { Serv_UControl sc = Serv_UControl.getServUContorl(); string homedir = sc.GetFtpUserHomeDir(glytm).Replace("\r", "");//获取管理员目录 string path = XMLHelper.getAppSettingValue("FTP_Home") + "\\Download\\" + CDString.getFileName(isbn + ztm) + "\\" + cdxh.Replace(" ", "_") + "\\"; DirectoryInfo dir = new DirectoryInfo(path); listFile = dir.GetFiles().ToList();//获取FTP服务器文件列表 FileInfo file = listFile.FirstOrDefault(); return(file.Length + "," + file.Extension); } catch { return(null); } }
[WebMethod]//移除文件 public bool RemoveFile(string glytm, string isbn, string ztm, string cdxh) { try { Serv_UControl sc = Serv_UControl.getServUContorl(); string homedir = sc.GetFtpUserHomeDir(glytm).Replace("\r", "");//获取管理员目录 string path = XMLHelper.getAppSettingValue("FTP_Home") + "\\Download\\" + isbn.Replace(" ", "_") + CDString.getFileName(ztm) + "\\" + cdxh.Replace(" ", "_"); DirectoryInfo dir = new DirectoryInfo(path); FileInfo file = dir.GetFiles().FirstOrDefault();//获取FTP服务器文件列表 if (file != null) { file.Delete();//删除文件 } if (dir.GetFiles().Count() < 1) { dir.Delete();//删除目录 } return(true); } catch { return(false); } }