Hello Code project members. I'm new to C++ and I want to make a software that does these steps:
1- Makes Downloads Directory.
2- Downloads text file that has name of files.
3- Moves the text file to the "Downloads" folder.
4- Reads the files names from the text file then downloads them.
My code:
*I've been searching for codes to make new folders and moving files ..etc, and I came across of system commands that can be used.
#include <tchar.h>
#include <iostream>
#include <urlmon.h>
#include <string>
#include "stdlib.h"
using namespace std;
#pragma comment(lib, "urlmon.lib")
int main()
{
string Dlfold;
cout << "Welcome to Latest Files downloader, this software will let you download the lastest Files added\nFirst I'll make download folder for you\n";
std::string s1 = "mkdir \Downloads\ ";
system(s1.c_str());
cout << "\nDownloads folder created, now let me check the latest releases...\n";
HRESULT hr = URLDownloadToFile(NULL, _T("http://example.com/latest.txt"), _T("Latest.txt"), 0, NULL);
std::string s2 = "move latest.txt \Downloads";
system(s2.c_str());
return 0;
}
The Code above does the two first steps, the file "Latest.txt" will have information like img1.png or video.mp4 which represents the name of files inside the directory.
I want the program to replace the names of files here:
ULL, _T("http://example.com/latest.txt")
*instead of "http://example.com/latest.txt" I want it automatically to change to "http://example.com/img1.png" and "http://example.com/vid1.mp4" just like the name of files that written in the text file.
your help will be appreciated!!
*I'm using windows by the way.