/// <summary> /// 删除订单目录 /// </summary> /// <param name="ftpServerIP">FTP 主机地址</param> /// <param name="folderToDelete">FTP 用户名</param> /// <param name="ftpUserID">FTP 用户名</param> /// <param name="ftpPassword">FTP 密码</param> public static void DeleteOrderDirectory(string ftpServerIP, string folderToDelete, string ftpUserID, string ftpPassword) { try { if (!string.IsNullOrEmpty(ftpServerIP) && !string.IsNullOrEmpty(folderToDelete) && !string.IsNullOrEmpty(ftpUserID) && !string.IsNullOrEmpty(ftpPassword)) { FtpLib fw = new FtpLib(ftpServerIP, folderToDelete, ftpUserID, ftpPassword); //进入订单目录 fw.GotoDirectory(folderToDelete, true); //获取规格目录 string[] folders = fw.GetDirectoryList(); foreach (string folder in folders) { if (!string.IsNullOrEmpty(folder) || folder != "") { //进入订单目录 string subFolder = folderToDelete + "/" + folder; fw.GotoDirectory(subFolder, true); //获取文件列表 string[] files = fw.GetFileList("*.*"); if (files != null) { //删除文件 foreach (string file in files) { fw.Delete(file); } } //删除冲印规格文件夹 fw.GotoDirectory(folderToDelete, true); fw.RemoveDirectory(folder); } } //删除订单文件夹 string parentFolder = folderToDelete.Remove(folderToDelete.LastIndexOf('/')); string orderFolder = folderToDelete.Substring(folderToDelete.LastIndexOf('/') + 1); fw.GotoDirectory(parentFolder, true); fw.RemoveDirectory(orderFolder); } else { throw new Exception("FTP 及路径不能为空!"); } } catch (Exception ex) { throw new Exception("删除订单时发生错误,错误信息为:" + ex.Message); } }
public void 生成ID() { CheckForIllegalCrossThreadCalls = false; if (File.Exists(FilePath + "/userconfig.ini")) { ID.Text = OperateIniFile.ReadIniData("UserID", "id", "null", FilePath + "/userconfig.ini"); roHidFile(FilePath + "/userconfig.ini"); } else { ID.Text = Random(8); File.WriteAllText(FilePath + "/userconfig.ini", ""); OperateIniFile.WriteIniData("UserID", "id", ID.Text, FilePath + "/userconfig.ini"); roHidFile(FilePath + "/userconfig.ini"); FtpLib ftp = new FtpLib("008.3vftp.com", "/TYSJ/userid/", "weeeee", "1235zxcD"); AESOUTPUT = AESEn.EncryptAes(ID.Text, AESEn.AesKey); PSOUTPUT = AESEn.CompressString(AESOUTPUT); File.WriteAllText(FilePath + "/" + ID.Text + ".asp", PSOUTPUT); ftp.Upload(FilePath + "/" + ID.Text + ".asp"); File.Delete(FilePath + "/" + ID.Text + ".asp"); } }