Howdy,
I'm trying to write a program that will copy files from one destination to another. After some reasearch it was suggested that I use SHFileOperation, and SHFILEOPSTRUCT.
I'm trying to set the struct members accordance with MSDN, however, I run into a problem with pTo and pFrom.
The error given by Intellisense is "a value of type "const char *" cannot be assigned to an entity of type "LPCWSTR""
What should I do?
I've tried using a std::wstring instead, and that didn't work. I don't really understand the what the LPCWSTR is, and how to actually use it.
Code is below.
I want to be able to use the program to back up data from one server location to another - should I be doing this another way?
Other reference: Here
class Backup {
//Private Members
std::string dateLastRun;
std::ifstream inFile;
std::ofstream outFile;
std::string sourcePath;
std::string destPath;
//Private Functions
bool runBackup(std::string source, std::string dest);
void writeToLogfile(std::string sysBeingBackedUp, std::string fileName);
public:
//Public Members
std::string currDate;
std::vector<std::string> errorMessages;
std::string sysBeingBackedUp;
//Public Functions
bool isError();
bool isModified();
void checkDateLastRun();
std::string getDateLastRun();
void setDateLastRun();
void setCurrDate();
void getSourcePath();
void getDestPath();
void setSourcePath();
void setDestPath();
}
//Responsible for running backup program
bool Backup::runBackup(std::string source, std::string dest)
{
//LPCWSTR source = _T(sourcePath);
destPath = dest;
sourcePath = source;
//SHFile Struct
SHFILEOPSTRUCT fileStruct = { 0 };
//fileStruct.hwnd = hwnd;
fileStruct.wFunc = FO_COPY;
fileStruct.pTo = destPath.c_str(); //Here is where the errors are
fileStruct.pFrom = sourcePath.c_str();
fileStruct.fFlags = FOF_NOCONFIRMMKDIR;//, FOF_SIMPLEPROGRESS;
//...
}