Home Forums .NET libraries Xceed SFTP/FTP for .NET No folder content returned by either GetFiles or GetItems

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • johnsondw@preit.com
    Participant
    Post count: 3
    #44429 |

    I am upgrading to Xceed FTP for .Net, version 5.8, but I have run into a problem.

    I have found two ways to get files from a remote server using the native FTP product. The first uses an array of AbstractFiles, and the GetFiles method on the AbstractFolder.

    private int FtpGet_ProcessRemoteFolderList_A() {
    int filesFound = 0;
    AbstractFolder remoteFolder = null;
    AbstractFile[] remoteFiles = new AbstractFile[500];
    try {
    remoteFolder = new FtpFolder(ftpConn);
    remoteFiles = remoteFolder.GetFiles(true, new NameFilter(“*.*”));
    filesFound = remoteFiles.GetLength(0);
    }
    catch (Exception ex) {
    errMsg = ex.ToString();
    }
    return filesFound;
    }

    When I run this, here is what the trace looks like:

    < 220 CONNECT:Enterprise Gateway 2.1.00. FTP Server ready…
    > USER prubin1
    < 331 Password required for prubin1.
    > PASS *****
    < 230 User prubin1 logged in. Session Id: 8456.
    > PWD
    < 257 “/prubin1” is current directory.
    > CWD /prubin1
    < 250 CWD command successful.
    > CWD /prubin1
    < 250 CWD command successful.
    > TYPE A
    < 200 TYPE set to A.
    > PASV
    < 227 PASV Entering passive mode (170,201,173,15,9,158).
    > LIST
    Data connection established with 170.201.173.15:2462 on 12/7/2016 @ 9:14:24 AM
    < 150 Opening data connection.
    < 226 Transfer complete.
    > QUIT
    < 221 Goodbye.

    If I remove the GetFiles line, I get this, which is missing the LIST command.

    < 220 CONNECT:Enterprise Gateway 2.1.00. FTP Server ready…
    > USER prubin1
    < 331 Password required for prubin1.
    > PASS *****
    < 230 User prubin1 logged in. Session Id: 10204.
    > PWD
    < 257 “/prubin1” is current directory.
    > QUIT
    < 221 Goodbye.

    I confirmed with the owners of the server I am connecting to that I am connecting, that the remote directory is the correct one, and there are over two dozen files in that folder.

    Then I used the second method, using an array of FileSystemItems, and the GetItems method.

    private int FtpGet_ProcessRemoteFolderList_B() {
    int itemsFound = 0;
    AbstractFolder remoteFolder = null;
    FileSystemItem[] items = new FileSystemItem[500];
    try {
    remoteFolder = new FtpFolder(ftpConn);
    items = remoteFolder.GetItems(true);
    itemsFound = items.GetLength(0);
    }
    catch (Exception ex) {
    errMsg = ex.ToString();
    }
    return itemsFound;
    }

    The results are identical. What am I missing?

    Fawzi [Xceed]
    Member
    Post count: 722

    Hi,

    It’s possible that component isn’t parsing the listing correctly or the server lists items in a format that is unknown to the component. Those IBM servers don’t always follow established standards.

    Let’s examine the raw contents of the listing to confirm or rule out our hypothesis. If you run the following code, what output do you get?

    FtpClient ftp = new FtpClient();
    http://ftp.Connect( “you host” );
    http://ftp.Login( “your username”, “your password” );

    StringList rawContents = GetRawFolderContents();

    http://ftp.Disconnect();

    Console.Write( rawContents.ToString() );

    Can you send us the value of the rawContents variable so we can analyze the format?

    johnsondw@preit.com
    Participant
    Post count: 3

    Interesting. When I use the GetRawFolderContents, I get exactly what I expect.

    {-ART——TCP B xatagpcd 11907 914 Dec 13 03:57 arp.pre.6333.out.161213.035749.pgp
    -ART——TCP B xatagpcd 12223 463 Dec 13 04:04 arp.pre94942.out.pgp.161213.040449.pgp
    -ART——TCP B xatagpcd 16096 2772 Dec 13 08:02 edi.10504.out.161213.080203
    -ART——TCP B xatagpcd 20467 385197 Dec 13 09:03 373228.out.zip.161213.090304.pgp
    -ART——TCP B xatagpcd 9897 743120 Dec 13 09:04 373281.out.zip.161213.090403.pgp
    -ART——TCP B xatagpcd 14879 192394 Dec 13 09:18 932624.out.zip.161213.091803.pgp
    -ART——TCP B xatagpcd 14863 333596 Dec 13 09:19 932633.out.zip.161213.091904.pgp
    -ART——TCP B xatagpcd 14840 1209138 Dec 13 09:20 932831.out.zip.161213.092003.pgp
    -ART——TCP B xatagpcd 14793 407206 Dec 13 09:22 373300.out.zip.161213.092203.pgp
    -ART——TCP B xatagpcd 14782 505750 Dec 13 09:24 373391.out.zip.161213.092403.pgp
    -ART——TCP B xatagpcd 14779 830047 Dec 13 09:24 373312.out.zip.161213.092403.pgp
    -ART——TCP B xatagpcd 14753 386913 Dec 13 09:26 373747.out.zip.161213.092603.pgp
    -ART——TCP B xatagpcd 14750 471566 Dec 13 09:27 373822.out.zip.161213.092703.pgp
    -ART——TCP B xatagpcd 14735 798974 Dec 13 09:28 373828.out.zip.161213.092803.pgp
    -ART——TCP B xatagpcd 14727 213917 Dec 13 09:29 373858.out.zip.161213.092903.pgp
    -ART——TCP B xatagpcd 14720 135889 Dec 13 09:30 373898.out.zip.161213.093004.pgp
    -ART——TCP B xatagpcd 14706 873793 Dec 13 09:31 373988.out.zip.161213.093104.pgp
    -ART——TCP B xatagpcd 14677 1472625 Dec 13 09:33 392406.out.zip.161213.093304.pgp
    -ART——TCP B xatagpcd 14666 422235 Dec 13 09:34 951316.out.zip.161213.093403.pgp
    -ART——TCP B xatagpcd 14614 173983 Dec 13 09:37 951696.out.zip.161213.093704.pgp
    -ART——TCP B xatagpcd 14537 483416 Dec 13 09:40 951738.out.zip.161213.094004.pgp
    -ART——TCP B xatagpcd 14516 1327724 Dec 13 09:41 951727.out.zip.161213.094103.pgp
    -ART——TCP B xatagpcd 14470 231218 Dec 13 09:43 951773.out.zip.161213.094303.pgp
    -ART——TCP B xatagpcd 14441 775961 Dec 13 09:44 951776.out.zip.161213.094403.pgp
    -ART——TCP B xatagpcd 12813 233698 Dec 13 10:03 932172.out.zip.161213.100312.pgp
    Total number of batches listed: 25
    }

    johnsondw@preit.com
    Participant
    Post count: 3

    Fawzi, any word on whether this can be fixed?

    Fawzi [Xceed]
    Member
    Post count: 722

    Hi Dwight,

    GetFiles and GetItems serve to get logical representations of the files and folders, in this case, the remote ftp files and folders.

    To actually download the files, you need to call one of the methods CopyFilesTo() or CopyTo(). These will copy the source files and/or folders to a destination you specify.

    Here’s an example based on your code:

    AbstractFolder remoteFolder = new FtpFolder(ftpConn);

    // Setup a local folder as the destination
    AbstractFolder localFolder = new DiskFolder( @”D:\Data” );

    // Download the files from the remote folder to the local folder
    remoteFolder.CopyFilesTo( localFolder, true, true );

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.