Hi,
as I wrote in my last post, the download of the file works.
I need to open the file just as the download is ready. So I did this:
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
// DOWNLOADING THE FILE
QFile *fileGet;
QHttp *httpGet;
httpGet = new QHttp();
fileGet = new QFile();
fileGet->setName("data.txt");
fileGet->open(IO_WriteOnly);
httpGet->setHost("finance.yahoo.com");
httpGet->get("/q/ks?s=GT", fileGet);
httpGet->closeConnection();
fileGet->close();
// OPENING THE FILE
std::string filename="data.txt";
std::string dummy;
std::ifstream file(filename.c_str());
if (file)
{
while (!file.eof())
{
std::getline(file, dummy);
std::cout << dummy << std::endl;
}
}
|
This doesn't work. It seems as if the file data.txt was empty. No line is plotted by the 'cout << dummy' command. Altough the file is filled.
But when I use the second part of the code (OPENING THE FILE) without the first part (DOWNLOADING THE FILE) before it (-> I open the data.txt from the last downlad) then the 'cout << dummy' shows the correct content of the file!
That makes me think that the data.txt isn't closed after the fileGet->close() command. Or something like this.
I hope you know what I mean.
Any idea?
Karl