Welcome to the Xceed Community Sign in | Join | Help
Community Search  

Does AsyncFtpClient contains an object to allow me to get file with latest timestamp on it?

Sort Posts: Previous Next
  •  05-07-2008, 3:25 PM Post no. 12049

    Does AsyncFtpClient contains an object to allow me to get file with latest timestamp on it?

    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

     

  •  05-08-2008, 11:00 AM Post no. 12090 in reply to 12049

    Re: Does AsyncFtpClient contains an object to allow me to get file with latest timestamp on it?

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

     </P><FONT size=2> <P>System.</FONT><FONT color=#008080 size=2>DateTime</FONT><FONT size=2> oDateTime = </FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> System.</FONT><FONT color=#008080 size=2>DateTime</FONT><FONT size=2>(2000, 1, 1, 0, 0, 0);</P></FONT><FONT size=2> <P></FONT><FONT color=#008000 size=2>//==============================================</P></FONT><FONT size=2> <P>Xceed.Ftp.</FONT><FONT color=#008080 size=2>FtpItemInfoList</FONT><FONT size=2> oFtpItemInfoList;</P> <P>oFtpItemInfoList = oAsyncFtpClient.GetFolderContents();</P> <P></FONT><FONT color=#008000 size=2>//MessageBox.Show("File: " + Convert.ToString(oFtpItemInfo.Name) + " (" + Convert.ToString(oFtpItemInfo.Size) + " bytes)");</P></FONT><FONT size=2> <P></FONT><FONT color=#0000ff size=2>foreach</FONT><FONT size=2> (Xceed.Ftp.</FONT><FONT color=#008080 size=2>FtpItemInfo</FONT><FONT size=2> oFtpItemInfo </FONT><FONT color=#0000ff size=2>in</FONT><FONT size=2> oFtpItemInfoList)</P> <P>{</P> <P></FONT><FONT color=#0000ff size=2>if</FONT><FONT size=2> ((oFtpItemInfo.Name != </FONT><FONT color=#800000 size=2>"."</FONT><FONT size=2>) &amp;&amp; (oFtpItemInfo.Name != </FONT><FONT color=#800000 size=2>".."</FONT><FONT size=2>))</P> <P>{</P> <P></FONT><FONT color=#0000ff size=2>if</FONT><FONT size=2> (oDateTime &lt; oFtpItemInfo.DateTime)</P> <P>{</P> <P>oDateTime = oFtpItemInfo.DateTime;</P> <P>sFtpFileame = oFtpItemInfo.Name;</P> <P>}</P> <P>}</P> <P>}</P> <P></FONT><FONT color=#008000 size=2>//==============================================</FONT></P> <P><FONT color=#008000 size=2>

     

    This one works pretty well.

  •  05-08-2008, 2:13 PM Post no. 12105 in reply to 12090

    Re: Does AsyncFtpClient contains an object to allow me to get file with latest timestamp on it?

    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;
        }
      }
    }
    //==============================================


    Charles Bérubé-Rémillard
    Technical Support
    Xceed Software Inc.
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.