I want to list all the files and folders in remote directory on server after connecting to the solaris 10 server.In server FTP functionality is disabled only SFTP is enabled.I need a method which will retrieve file as a file and also folder as a folder type.I am able to connect to the server using sftp and jsch-0.1.44.jar file.

asked 21 Jul '11, 11:26

karthickgedms's gravatar image

karthickgedms
15
accept rate: 0%


I'm not sure I completely understand what exactly is the problem here. In Rebex FTP, there is FtpItem object and FtpList object (a collection of FtpItem objects). In Rebex SFTP, there is SftpItem and SftpItemCollection (a collection of SftpItem objects. FtpItem is very similar to SftpItem and FtpList is very similar to SftpItemCollection.

To check whether an item is a file or directory, you can either use IsFile and IsDirectory properties or the Type property. Example:

        Sftp sftp = new Sftp();
        sftp.Connect("server01", 22);
        sftp.Login("tester01", "password");

        SftpItemCollection list = sftp.GetList();
        foreach (SftpItem item in list)
        {
            // display last modification date    
            Console.Write(item.Modified.ToString("u"));

            // display item type (usually a directory or file)
            Console.Write(item.Type.ToString().PadLeft(16, ' '));

            // display item size
            Console.Write(item.Size.ToString().PadLeft(10, ' '));

            // display item name
            Console.Write(" {0}", item.Name);
            Console.WriteLine();
        }
link

answered 21 Jul '11, 13:03

Lukas%20Pokorny's gravatar image

Lukas Pokorny ♦♦
2.4k28
accept rate: 31%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×141

Asked: 21 Jul '11, 11:26

Seen: 228 times

Last updated: 21 Jul '11, 13:03