Beispiel #1
0
        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));
                }
            }
        }
Beispiel #2
0
        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);
            }
        }
Beispiel #3
0
 public void PushValues(SftpFilesValuesProviderArgs args, SftpConnectionInfo connectionInfo, Action <SftpFilesValue> pushValue)
 {
     GetFiles(connectionInfo, args.Path).ToList().ForEach(pushValue);
 }
Beispiel #4
0
 public SftpFilesValue(SftpConnectionInfo connectionInfo, string path, string name)
 {
     this.Name            = name;
     this._path           = path;
     this._connectionInfo = connectionInfo;
 }