Chilkat Forum

Technologies => FTP => Topic started by: Chilkat on November 02, 2017, 09:37:16 AM

Title: Async methods for FTP GetFilename, GetSize, etc.?
Post by: Chilkat on November 02, 2017, 09:37:16 AM
Quick question please. I want to get the contents information of a directory asynchronously (FTP object). From what Iíve seen in your documentation you have the method GetFilename, GetSize, etc ( ( I was wondering if you could suggest a way to get the fileName, size, isDirectory (Yes or No) and the itemPermission asynchronously.
Title: Re: Async methods for FTP GetFilename, GetSize, etc.?
Post by: Chilkat on November 02, 2017, 09:51:02 AM
I think some clarification is all that's needed.

The referenced example calls GetDirCount, and then loops over the directory entries, calling GetFilename, GetSize, etc.    The call to GetDirCount fetches (downloads) the directory listing from the FTP server.  The calls to GetFilename, GetSize, etc. are simply returning information from the already-downloaded (cached) directory listing.  Therefore, there is no need for async methods for GetFilename, GetSize, etc. because those methods don't communicate with the FTP server.

It is the GetDirCount method that potentially communicates with the FTP server to download the directory listing, and it has a corresponding GetDirCountAsync method.  In fact, any method in any Chilkat class that communicates over the Internet will automatically have a corresponding Async method.  If no Async method exists, such as for GetFilename, then you'll know that it does not communicate over the Internet.

The GetDirCount method will only fetch a new directory listing if the cached copy is not fresh.  For example, if your application changes the current remote directory, then the cache is no longer fresh and the next call to GetDirCount will fetch the new directory listing.  Also, if you change the ListPattern property, then the next call to GetDirCount will re-fetch.     To clarify further: Let's say the directory cache is not fresh (or has never been downloaded) and you call GetDirCount two times in a row.  The 1st call will fetch the directory listing and return the count.  The 2nd call will find a valid cached directory listing and simply return the count.