This project is read-only.
1
Vote

How to use GetFile to retrieve Uncached files

description

Thank you for developing the FTPLIB component. Currently the call to FtpGetFile will always return back the Cached version of the file. In my application I am retrieving a file that changes frequently so it did not for me. I researched to how to solve the problem and found that I need to add the INTERNET_FLAG_RELOAD to the dwflags parameter in the call to GetFile.

I found the that the value in WinAPIs.cs for {public const int INTERNET_FLAG_RELOAD = 8;}
should have been {public const Int32 INTERNET_FLAG_RELOAD = 0x80000000;} 0x80000000 is to large for the int variable. I then needed to modify all (DWORD) mappings from Int to Int32 so it would compile.

I also added Uncached calls to GetFile
    public void GetFileUnCached(string remoteFile, string localFile, bool failIfExists)
    {
        int ret = WININET.FtpGetFile(_hConnect,
             remoteFile,
             localFile,
             failIfExists,
             WINAPI.FILE_ATTRIBUTE_NORMAL,
             WININET.FTP_TRANSFER_TYPE_BINARY + INTERNET_FLAG_RELOAD,
             IntPtr.Zero);

        if (ret == 0)
        {
            Error();
        }
    }

comments