Tamir.SharpSsh.Sftp.GetFileList C# (CSharp) Method

GetFileList() public method

public GetFileList ( string path ) : IEnumerable
path string
return IEnumerable
		public IEnumerable<String> GetFileList(string path)
		{
            return SftpChannel.ListEntries(path).Select(LsEntry => LsEntry.FileName);
		}

Usage Example

Exemplo n.º 1
2
        public bool GetFiles()
        {
            bool status = true;

            Sftp sftp = new Sftp( m_sftpSite, m_sftpSiteUserName );
            try
            {
                // add our private key to connect
                // put these in the config file
                sftp.AddIdentityFile(@"d:\apps\RSAKeys\opensshkey");

                // connect
                sftp.Connect();

                // get a directory list
                ArrayList rFiles = sftp.GetFileList( m_sftpSiteRemoteFolder );
                foreach ( string file in rFiles )
                {
                    if (file.Equals(".") || file.Equals(".."))
                        continue;

                    // get the file and put in the watch folder to be processed
                    sftp.Get(m_sftpSiteRemoteFolder + file, m_moveToProcessFolder + file);

                    // update our database that we have downloaded the file from the server
                    // this.updateDb( file );

                    // delete the file on the remote server after pulling it over
                    // sftp.Delete(f);
                }

                sftp.Close();
                status = true;

            }
            catch (Tamir.SharpSsh.jsch.SftpException se)
            {
                LogMsg("NEXCEPTION:SftpMgr::GetFile():ECaught:" + se.Message);
            }
            catch (Tamir.SharpSsh.jsch.JSchException jse)
            {

                LogMsg("NEXCEPTION:SftpMgr::GetFile():ECaught:" + jse.Message);
            }
            catch (Tamir.SharpSsh.SshTransferException ste)
            {
                LogMsg("NEXCEPTION:SftpMgr::GetFile():ECaught:" + ste.Message);
            }
            catch (SystemException se)
            {
                LogMsg("NEXCEPTION:SftpMgr::GetFile():ECaught:" + se.Message);
            }

            return status;
        }
All Usage Examples Of Tamir.SharpSsh.Sftp::GetFileList