Hi!
I tried to do a simple text file copy like this:
Code:
BROWSEINFO bi;
::ZeroMemory(&bi, sizeof(bi));
TCHAR szSelPath[MAX_PATH];
bi.pszDisplayName = szSelPath;
bi.lpszTitle = "Select the folder/file";
bi.ulFlags =
BIF_BROWSEINCLUDEFILES |
BIF_EDITBOX |
BIF_RETURNFSANCESTORS |
BIF_STATUSTEXT |
BIF_VALIDATE ;
LPITEMIDLIST pidlSrc = ::SHBrowseForFolder(&bi);
char pathSrc[50], pathSrcTemp[50];
SHGetPathFromIDList(pidlSrc,pathSrc);
int j = 0;
for(int i=0; pathSrc[i]!='\0'; i++,j++){
pathSrcTemp[j]=pathSrc[i];
if(pathSrcTemp[j]=='\\'){
j++;
pathSrcTemp[j]='\\';
}
}
pathSrcTemp[j] = '\0';
SHFILEOPSTRUCT shfos;
shfos.hwnd = NULL;
shfos.wFunc = FO_COPY;
shfos.pFrom = pathSrcTemp;
shfos.pTo = "F:\\hi1.txt";
shfos.fFlags = FOF_ALLOWUNDO;
::SHFileOperation(&shfos);
But it isn’t working. I think there is something wrong with string pathSrcTemp. What can I do to fix this, please?
Thanks.
-geek@02