CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2003
    Location
    CA
    Posts
    38

    App downloaded file being cached somewhere…

    I have a simple application which is running on a Vista PC. During a certain function, it is supposed to download a .csv file from my FTP server, append some data and upload the new file (same name).

    It works great the first time I launch the application, but when I make subsequent calls to the append function it appends the data to some hidden/cached version of the original downloaded file and uploads that file. This means only the last entry ever shows up on the FTP file copy, as the application uses the same original download file to append to ever time. It is supposed to be downloading the latest version from the FTP site each time, but it isn’t.

    After the initial download, I can remove the file from the FTP site and as long as I don’t close and reopen my application it keeps grabbing the cached version of the file and doesn’t throw any errors. If I close and reopen the application after deleting the FTP file it accurately warns me that the file could not be downloaded.

    How do I get around this? It works fine on two Vista PCs but not on two others. Same application, very different results.

    If I search for the file by name on the PC it shows the downloaded file and I can delete it, and the append call, downloads it again but as stated this is the original download and not what is or isn’t on the FTP server. Searching hidden files and folders turns up 4 hidden versions but I cannot see what folder they are in or find any information on them. The advanced search just says it finds 4 plus the original, and I can only interact with the original.

    Please help. Thank you.

  2. #2
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: App downloaded file being cached somewhere…

    Which api did u call for ftp file download ?

  3. #3
    Join Date
    May 2003
    Location
    CA
    Posts
    38

    Re: App downloaded file being cached somewhere…

    I am using "URLDownloadToFile". Thanks for any ideas or solutions.

  4. #4
    Join Date
    Nov 2007
    Posts
    35

    Re: App downloaded file being cached somewhere…

    Search MSDN for INTERNET_FLAG_NO_CACHE_WRITE

    I've used the function in AutoHotKey which prevents fetching from the cache by default. According to their docs you can stick a star '*' then a number, such as INTERNET_FLAG_NO_CACHE_WRITE then a space, before the URL to tell it how to handle things like caching etc..

    In their example url, this allows caching: *0 http://someorg.org

    So I assume the 0 can be replaces by one of the defines in the docs for the API call.

    Some trial and error should get it.

  5. #5
    Join Date
    May 2003
    Location
    CA
    Posts
    38

    Re: App downloaded file being cached somewhere…

    Thanks for the reply MilesAhead. I will look into your suggestion, but also just found a solution in the CodeGuru forums which seems to work. Before downloading the the file I call DeleteUrlCacheEntry( URL ); which removes the cached file so subsequent download has to actually get the latest file from the FTP site.

    Thanks again.

  6. #6
    Join Date
    Nov 2007
    Posts
    35

    Re: App downloaded file being cached somewhere…

    Quote Originally Posted by StoneRaven View Post
    Thanks for the reply MilesAhead. I will look into your suggestion, but also just found a solution in the CodeGuru forums which seems to work. Before downloading the the file I call DeleteUrlCacheEntry( URL ); which removes the cached file so subsequent download has to actually get the latest file from the FTP site.

    Thanks again.
    Thanks for posting what you found. That may be handy in the future as not all implementations have the little "add ons" that scripting languages stick in there.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured