This question already has answers here:
How can I prevent URLDownloadToFile from retrieving from the cache?
                                
                                    (4个答案)
                                
                        
                                4年前关闭。
            
                    
vector<string> DownloadList()
{
LPCSTR site = "somesite.com/uploads/2/9/8/8/29880261/users.txt";
LPCSTR path = "C:\\Users\\Public\\Favorites\\users.txt";
URLDownloadToFile(NULL, site, path , 0, NULL);
ifstream file;
string line;
vector<string> lines;
file.open(path);
while (getline(file, line)) {
    lines.push_back(line);
}
file.close();
DeleteFileA(path);
return lines;
}


即使将文件重新上传到站点,该程序也会下载并读取前一个文件?旧文件是否保存在内存中?我不明白。旧文件已下载,但新文件已上传并存在于url中。我该如何解决?

最佳答案

发生这种情况是因为文件被系统缓存。使用API​​函数DeleteUrlCacheEntry删除缓存的文件(在调用URLDownloadToFile之前)

10-06 09:26