// 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))); } } } }
// Download file from IFS public void GetFile(string serverPath, string clientPath) { var fileName = Path.GetFileName(serverPath); var outPath = ClientUtils.BuildDownloadPath(clientPath, Profile); if (!Path.HasExtension(outPath)) { outPath = Path.Combine(outPath, fileName); } using (KanpachiClient client = new KanpachiClient(Profile)){ Console.WriteLine($"Downloading {serverPath} to {outPath}"); File.WriteAllText(outPath, Encoding.UTF8.GetString(client.DownloadFile(serverPath))); } }