public FTPDirectory(bool isFolderPicker, FTPCredentialsConfig ftpcreds) { InitializeComponent(); this.isFolderPicker = isFolderPicker; ImageList smallimagelist = new ImageList(); smallimagelist.Images.Add(Bitmap.FromFile("resources\\icons\\folderimage.bmp")); smallimagelist.Images.Add(Bitmap.FromFile("resources\\icons\\fileimage.bmp")); listView1.SmallImageList = smallimagelist; ftpUtils = new FTPUtils(ftpcreds); ftpUtils.startSession(); if (!String.IsNullOrEmpty(path)) { remoteFileInfoList = ftpUtils.getDirectoryListing(path, isFolderPicker, false); previousPath = path; } else { remoteFileInfoList = ftpUtils.getDirectoryListing("/", isFolderPicker, false); } loadDataToListview(); tbpath.Text = previousPath; }
private List <string> getFtpDirectoryListing(firedumpdbDataSet.backup_locationsRow location, string path) { List <string> filesindir = new List <string>(); FTPCredentialsConfig ftpConfig = new FTPCredentialsConfig(); ftpConfig.id = location.id; ftpConfig.host = location.host; ftpConfig.port = (int)location.port; ftpConfig.username = location.username; ftpConfig.password = location.password; if (location.usesftp == 1) { ftpConfig.useSFTP = true; ftpConfig.SshHostKeyFingerprint = location.ssh_key_fingerprint; } if (!string.IsNullOrEmpty(location.ssh_key)) { ftpConfig.usePrivateKey = true; ftpConfig.privateKeyPath = location.ssh_key; } FTPUtils ftputils = new FTPUtils(ftpConfig); ftputils.startSession(); List <WinSCP.RemoteFileInfo> dirList = ftputils.getDirectoryListing(path, false, false); ftputils.disposeSession(); foreach (WinSCP.RemoteFileInfo info in dirList) { filesindir.Add(info.FullName); } return(filesindir); }