2015-05-04 43 views
0
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; 
} 

即使文件重新上传到站点,程序也会下载并读取以前的文件?旧文件是否保存在内存或其他东西?我没有明白。旧文件已下载,但新文件已上传并存在于网址中。我如何解决这个问题?C++ WinAPI URLDownloadToFile(urlmon)bug

回答

4

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

+0

非常感谢! – Nullptr

+0

当然,如果它有帮助,请标记为已解决。 – Adrian