Click here to Skip to main content
15,667,577 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
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\ ";
	cout << "\nDownloads folder created, now let me check the latest releases...\n";
	HRESULT hr = URLDownloadToFile(NULL, _T(""), _T("Latest.txt"), 0, NULL);
	std::string s2 = "move latest.txt \Downloads";
	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("")

*instead of "" I want it automatically to change to "" and "" just like the name of files that written in the text file.

your help will be appreciated!!
*I'm using windows by the way.
Andreas Gieriet 10-Oct-14 8:51am    
Why re-inventing the wheel? Why not using wget?

1 solution

At first you should learn the basics in string operations. You can append, delete and replace in strings.

And then read and download the fine article about FileDownload.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900