private IEnumerable <SftpFilesValue> GetFiles(SftpConnectionInfo sftpConnectionInfo, string path) { var connectionInfo = sftpConnectionInfo.CreateConnectionInfo(); using (var client = new SftpClient(connectionInfo)) { client.Connect(); var files = client.ListDirectory(path); foreach (var file in files) { yield return(new SftpFilesValue(sftpConnectionInfo, path, file.Name)); } } }
private void WriteSftpFile(SftpConnectionInfo sftpConnectionInfo, string outputPath, Stream stream) { var connectionInfo = sftpConnectionInfo.CreateConnectionInfo(); using (var client = new SftpClient(connectionInfo)) { client.Connect(); byte[] fileContents; stream.Position = 0; using (MemoryStream ms = new MemoryStream()) { stream.CopyTo(ms); fileContents = ms.ToArray(); } client.WriteAllBytes(outputPath, fileContents); } }
public void PushValues(SftpFilesValuesProviderArgs args, SftpConnectionInfo connectionInfo, Action <SftpFilesValue> pushValue) { GetFiles(connectionInfo, args.Path).ToList().ForEach(pushValue); }
public SftpFilesValue(SftpConnectionInfo connectionInfo, string path, string name) { this.Name = name; this._path = path; this._connectionInfo = connectionInfo; }