N
N
noytmant2020-12-24 07:25:08
C++ / C#
noytmant, 2020-12-24 07:25:08

Show old value instead of new (std::stream)?

In general:
1) I upload a text file
2) Then I open it and set the value to the ss line

std::remove("base.txt"); // Удаляю старый файл, если он имеется
URLDownloadToFile(0, "url/base.txt", "base.txt", 0, 0);
std::ifstream f("base.txt");
std::stringstream ss;
ss << f.rdbuf();
f.close();

I opened the base.txt file, read it, got the value (string) and assigned the string to ss
Next comes the check
if(ss.str() == "OK")
{
   Load();
}
else
{
   Exit();
}

The first time it downloads the file, we see OK there and calls the Load () function;
Next, I close the application, go to the hosting and change the value, now it’s not OK, but NO
. I start the application, now we got the NO value, but the code checks for OK, now the Exit () function should be called;
But that was not the case, it calls the Load() function because the value of the file was OK, not NO
Whatever value I write in a text file, it shakes it and somehow magically leaves the old value there. But after all, a new file has been downloaded, with a new word, from where the old one suddenly appeared instead of the new one. Maybe I didn't add something? Or is the code wrong? Help solve this problem =(

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2020-12-24
@jcmvbkbc

I opened the base.txt file, read it, got the value (string) and assigned the string to ss
URLDownloadToFile(0, "url/base.txt", "base.txt", 0, 0);
std::remove("base.txt"); // Удаляю старый файл, если он имеется
std::ifstream f("base.txt");

But I see that you first start downloading the file, then delete it, and then open it. How should it work?
The second is URLDownloadToFile just starting the download. When it ends you do not check.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question