/// <summary> /// 創建文件夾 /// </summary> /// <param name="path">路徑</param> /// <param name="Mappath">文件名數組</param> public void CreateFolder(string path, string[] Mappath) { FTP ftp = null; try { string fullPath = path; foreach (string s in Mappath) { ftp = new FTP(fullPath.Substring(0, fullPath.Length - 1), ftpuser, ftppwd); fullPath += s; if (!ftp.DirectoryExist(s.Replace("/", ""))) { // ftp = new FTP(fullPath.Substring(0, fullPath.Length - 1), ftpuser, ftppwd); ftp = new FTP(fullPath, ftpuser, ftppwd); ftp.MakeDirectory(); } fullPath += "/"; } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); } }
/// <summary> /// 創建多層文件夾 /// </summary> /// <param name="path">路徑</param> /// <param name="Mappath">文件名</param> public void MakeMultiDirectory(string path, string[] Mappath, string ftpuser, string ftppwd) { FTP ftp = null; string fullPath = path; foreach (string s in Mappath) { ftp = new FTP(fullPath.Substring(0, fullPath.Length - 1), ftpuser, ftppwd); fullPath += s; if (!ftp.DirectoryExist(s.Replace("/", ""))) { ftp = new FTP(fullPath, ftpuser, ftppwd); ftp.MakeDirectory(); } fullPath += "/"; } }