Home Forums .NET libraries Xceed SFTP/FTP for .NET Does AsyncFtpClient contains an object to allow me to get file with latest timestamp on it?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #20974 |

    Hi!

    I’m looking at the AsyncFtpClient objects and I was wondering which objects if there is any that would fetch me a file (1 file only) with the latest timestamp on it.  On the FTP Server, the file is created weekly and is archived on the FTP Server.  So, each one of those file contain pretty much the same data except that each of the newer file contain additional (or newer) data.  So, I only need to fetch the latest file.

     Thanks,

     Scott

     

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Scott (had 1600 views)

    User (Old forums)
    Member
    Post count: 23064

    Um…  I can do something like this one instead…  Just view the directory first then attempt to transfer it afterward…

     [code]

    System.

    DateTime oDateTime = new System.DateTime(2000, 1, 1, 0, 0, 0);

    //==============================================

    Xceed.Ftp.

    FtpItemInfoList oFtpItemInfoList;

    oFtpItemInfoList = oAsyncFtpClient.GetFolderContents();

    //MessageBox.Show(“File: ” + Convert.ToString(oFtpItemInfo.Name) + ” (” + Convert.ToString(oFtpItemInfo.Size) + ” bytes)”);

    foreach (Xceed.Ftp.FtpItemInfo oFtpItemInfo in oFtpItemInfoList)

    {

    if ((oFtpItemInfo.Name != “.”) && (oFtpItemInfo.Name != “..”))

    {

    if (oDateTime < oFtpItemInfo.DateTime)

    {

    oDateTime = oFtpItemInfo.DateTime;

    sFtpFileame = oFtpItemInfo.Name;

    }

    }

    }

    //==============================================

    [/code]

     

    This one works pretty well.

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by Scott (had 515 views)

    Xceed Support
    Member
    Post count: 5658

    That’s a good solution. You could have also use the Synchronization mechanisms (it might require more coding).

    Formatted code:

    System.DateTime oDateTime = new System.DateTime(2000, 1, 1, 0, 0, 0);
    //==============================================
    Xceed.Ftp.FtpItemInfoList oFtpItemInfoList;
    oFtpItemInfoList = oAsyncFtpClient.GetFolderContents();
    MessageBox.Show(“File: ” + Convert.ToString(oFtpItemInfo.Name) + ” (” + Convert.ToString(oFtpItemInfo.Size) + ” bytes)”);
    foreach(Xceed.Ftp.FtpItemInfo oFtpItemInfo in oFtpItemInfoList)
    {
      if((oFtpItemInfo.Name != “.”) && (oFtpItemInfo.Name !=”..”))
      {
        if(oDateTime < oFtpItemInfo.DateTime)
        {
          oDateTime = oFtpItemInfo.DateTime;
          sFtpFileame = oFtpItemInfo.Name;
        }
      }
    }
    //==============================================

    Applies to Xceed FTP for .NET. Imported from legacy forums. Posted by CharlesB (had 2667 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.