// 재귀 호출 public bool DownloadDir(string strLocalDir, string strTargetDir) { FTPDirectory directory = ListDirectoryDetail(strTargetDir); for (int i = 0; i < directory.Count; i++) { if (directory[i].FileType == FTPFile.DirectoryEntryTypes.Directory) { DownloadDir(strLocalDir, directory[i].FullName + "/"); } else if (directory[i].FileType == FTPFile.DirectoryEntryTypes.File) { string strLocalFileName = strLocalDir + directory[i].FullName; // 폴더 만들기 System.IO.DirectoryInfo _directoryinfo = new System.IO.DirectoryInfo(strLocalDir + directory[i].Path); if (_directoryinfo.Exists == false) { _directoryinfo.Create(); } Download(directory[i].FullName, strLocalFileName, true); } } return(true); }
// 仅文件夹内部文件 public bool DownloadFolderFile(string strLocalDir, string strTargetDir) { FTPDirectory directory = ListDirectoryDetail(strTargetDir); if (directory == null) { return(false); } for (int i = 0; i < directory.Count; i++) { if (directory[i].FileType == FTPFile.DirectoryEntryTypes.File) { string strLocalFileName = strLocalDir + directory[i].FileName; if (strLocalFileName.Contains(".")) { Download(directory[i].FullName, strLocalFileName, true); } else { string name = strLocalFileName + "//"; string dir = strTargetDir + "//"; DownloadFolderFile(name, dir); } } } return(true); }
private FTPDirectory GetFileOrDir(FTPFile.DirectoryEntryTypes type, string strExt) { FTPDirectory result = new FTPDirectory(); foreach (FTPFile fi in this) { if (fi.FileType == type) { if (strExt == "") { result.Add(fi); } else if (strExt == fi.Extension) { result.Add(fi); } } } return(result); }
public bool DownloadPatch(string strLocalDir, string strTargetDir, string strDepthDir) { FTPDirectory directory = ListDirectoryDetail(strTargetDir); for (int i = 0; i < directory.Count; i++) { if (directory[i].FullName.Contains(".svn") == true) { continue; } if (directory[i].FileType == FTPFile.DirectoryEntryTypes.File) { string strLocalFileName = string.Empty; if (strDepthDir != "") { strLocalFileName = strLocalDir + strDepthDir + "/" + directory[i].FileName; if (Directory.Exists(strLocalDir + strDepthDir) == false) { Directory.CreateDirectory(strLocalDir + strDepthDir); } } else { strLocalFileName = strLocalDir + directory[i].FileName; } //FTPUpdateValue.DOWNLOADINDEX++; Download(directory[i].FullName, strLocalFileName, true); } else if (directory[i].FileType == FTPFile.DirectoryEntryTypes.Directory) { DownloadPatch(strLocalDir, directory[i].FullName + "/", strDepthDir + "/" + directory[i].FileName); } } return(true); }