Downloading my programs data from a webserver (Its basically just a .exe turned into .txt) but when I put it into a .exe it does not run?

So currently I am using a basic Http request to pull the exe data from my server
it returns my program in .txt form but when I put it into a file it will not run.
I assume this is because I need metadata but have no clue how to find that process or even how to google something as specific as that… So I am either asking for a solution (how to add proper .exe metadata) or if there is a better way to download files like that in C++

*Note I cannot use basic windows functions such as DownloadToFileA or External Library’s (Like LibCurl/Curl)"C:\\Users\\Program.exe").c_str(), std::ios::out);
if (OutFile.is_open())
     OutFile << Output;
     //Initialize .exe Meta Data???  

>Solution :

You need to open your file in binary mode otherwise newline translation will screw up your executable:"C:\\Users\\Program.exe").c_str(), std::ios::out | std::ios::binary);

Leave a Reply