// String To Wide String Copy File Example
// By Ben 20:10 23/09/2016

#include <iostream>
#include <Windows.h>

using namespace std;
using std::cout;
using std::endl;

wstring StrToWStr(string src){
	//Convert string to wide string
	wstring wstr(src.begin(), src.end());
	//return wide string
	return wstr;
}

int main(int argc, char *argv[]){
	//Char to wide string.
	string sFrom = "C:\\ben\\test.txt";
	string sTo = "C:\\ben\\test.bak";

	//Copy test.txt in c:\ben to test.bak
	if (!CopyFile(StrToWStr(sFrom).c_str(), StrToWStr(sTo).c_str(), false)){
		cout << "Error copying file." << endl;
		exit(1);
	}

	cout << "File was copyed." << endl;
	return 0;
}