// List contents of IFS directory public void ListDirectory(string serverPath) { var ifsPath = (serverPath == null || serverPath.Length == 0) ? Profile.IfsUserPath : serverPath; using (KanpachiClient client = new KanpachiClient(Profile)){ var entries = client.ListDirectory(ifsPath); foreach (SftpFile entry in client.ListDirectory(ifsPath)) { Console.WriteLine(entry.FullName); } } }
// download each file and directory recursively from IFS private void GetDirectoryRecursively(KanpachiClient client, string serverPath, string outPath) { Console.WriteLine($"Downloading directory {serverPath} to {outPath}"); foreach (SftpFile f in client.ListDirectory(serverPath)) { if (f.Name != "." && f.Name != "..") { if (f.IsDirectory) { var outSubPath = Path.Combine(outPath, f.Name); if (!Directory.Exists(outSubPath)) { Directory.CreateDirectory(outSubPath); } GetDirectoryRecursively(client, f.FullName, outSubPath); } else { var outFile = Path.Combine(outPath, f.Name.Replace('/', Path.DirectorySeparatorChar)); Console.WriteLine($"Downloading file {f.FullName} to {outFile}"); File.WriteAllText(outFile, Encoding.UTF8.GetString(client.DownloadFile(f.FullName))); } } } }