Click to See Complete Forum and Search --> : Wininet : Cache problem
Zolix2010
September 19th, 2005, 02:58 AM
hi,
im trying to download a file with :
InternetReadFile or URLDownloadToFile.
i did succeed to work with those functions - BUT! i want to download from the server and not use the cache files.
i did tried to add some flags of no cache use but with no success.
anyone got any inlights?
Avi.
golanshahar
September 19th, 2005, 03:28 AM
mmmm i have a little idea that might worked ( i didnt try it )
why dont you use the ::URLDownloadToCacheFile (..) (http://msdn.microsoft.com/library/default.asp?url=/workshop/networking/moniker/reference/functions/urldownloadtocachefile.asp) now it will download file directly to cache and will return you the path to it, you will do with the file whatever you want and then you will delete it from cache, and then in the next session since the file wont be present in the cache it will be always downloaded from site. ;)
hope it helps
Cheers
Zolix2010
September 19th, 2005, 03:31 AM
nice idea,
i tried that function before but i always got Access Violation bcuz of the fileBufferSize parameter.
got any idea what to set to it?
golanshahar
September 19th, 2005, 05:24 AM
nice idea,
i tried that function before but i always got Access Violation bcuz of the fileBufferSize parameter.
got any idea what to set to it?
try this:
char szFileName[MAX_PATH]={0};
char szUrl[MAX_PATH]={0};
::strcpy(szFileName,"index.html");
::strcpy(szUrl,"http://www.codeguru.com/index.html");
DWORD dwSize = sizeof(szFileName);
::URLDownloadToCacheFile(0,szUrl,szFileName,dwSize,0,0);
/EDIT
another functions that may be useful for you to search for file in the cache and delete it before downloading it.
FindFirstUrlCacheEntry(..) (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wininet/wininet/findfirsturlcacheentry.asp)
FindNextUrlCacheEntry(..) (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wininet/wininet/findnexturlcacheentry.asp)
DeleteUrlCacheEntry(..) (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wininet/wininet/deleteurlcacheentry.asp)
Cheers
Zolix2010
September 19th, 2005, 06:54 AM
thanks!
it works!
:wave:
Avi.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.