I'm having some difficulties with the PathCombine function. It does not seem to work correctly in conjunction with SHFileOperation(). My code is as follows:
//beginning of method
TCHAR* root = new TCHAR[MAX_PATH];
root = L"C:\\Users\\jhow\\Desktop\\\0";
//later on in the method
TCHAR* t1Dir = new TCHAR[MAX_PATH]; //root
TCHAR* t2Dir = new TCHAR[MAX_PATH]; //temp
PathCombine(t1Dir,root,L"Folder1\\%REPLACE_THIS%\\\0");
PathCombine(t2Dir,root,L"Folder1\\temp\0");
sf.pFrom = t1Dir;
//sf.pFrom = L"C:\\Users\\jhow\\Desktop\\Folder1\\%REPLACE_THIS%";
sf.pTo = temporaryDir;
//Copy files
int n = SHFileOperation(&sf);
When I have it like it is above, the method sees sf.pTo, but for some reason it does not see sf.pFrom (even after playing around with different combinations of the \ and \0 at the end of the path name). n becomes 2, which I think means file not found... But for example, when I comment out.
sf.pFrom = t1Dir;
and replace it with:
sf.pFrom = L"C:\\Users\\jhow\\Desktop\\Folder1\\%REPLACE_THIS%";
SHFileOperation() works... it returns zero and I can see that all the files are copied into the directory. I find this odd seeing as they appear to be the same exact string (even when I debug and hover over the variables)... Anyone happen to know why this is happening? Is there something wrong with my syntax or logic? Because I don't see it. I am using Visual Studio 2008. Thank you very much for your time.