Link to home
Start Free TrialLog in
Avatar of pb_india
pb_india

asked on

CopyFile

I am not sure why CopyFile is failing. Below is code snippet. Can you help me debug? copyfile fnc returns Zero. permPath is Temp dir loaction on C:\ and I checked it is fine.

if ((hFind = FindFirstFile(L"*", &fd)) != INVALID_HANDLE_VALUE)
      {
            do
            {

            if (wcscmp(CAU_PKG_SIGN_FILE_NAME, fd.cFileName) &&
                        wcscmp(L".", fd.cFileName) &&
                        wcscmp(L"..", fd.cFileName) )
                  {
                        wstring newFileName = permPath + wstring(fd.cFileName);
                        if (!CopyFile(fd.cFileName,(wchar_t*) newFileName.c_str(), FALSE))
                        {
                                                                                          permPath.erase();
                              break;
                        }
                  }
            }
            while (FindNextFile(hFind, &fd));
            FindClose(hFind);
      }
ASKER CERTIFIED SOLUTION
Avatar of Axter
Axter
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you're current working directory is not in the same location as where the file is at, then you'll need to give a full path and file name to CopyFile API for the source.