cFileName only contains the file name. You need to create an absolute path:
Code:string oldpath = "C:\\specfilesin\\" + string(FindData.cFileName); string newpath = "c:\\specfilesout\\" + ext.substr(1,3) + "\\" + curfilename; if (!MoveFile(oldpath.c_str(), newpath.c_str())) { cout << "Failed with error: " << GetLastError() << endl; cout << "See Win32 Error Code list." << endl; }