windows - CopyFile succeed, MoveFile fails with the same parameters - C++ -
i dealing frustrating problem in c++. need use movefile function fails. right using copyfile this:
partialresult = l"d:\\cppwork\\test2\\dectobin.exe"; finala = l"d:\\cppwork\\test2\\pefiles_\\dectobin.exe"; if (0 == copyfile(partialresult, finala,b)) {///// dword err = getlasterror(); std::cout << " -> copy fail" << std::endl; }
copy works ok if replace copyfile movefile (without changing paths) fails code 0x20 (msdn doc ->error_file_not_found). if try replace movefile copyfile , deletefile file previews path, copy works delete fails again error_file_not_found.
bool b = false; if (0 == copyfile(partialresult, finala,b)) {//copy works when try delete file give error dword err = getlasterror(); std::cout << " -> copy fail" << std::endl; outfile << " -> copy fail" << std::endl; } else { std::cout << " -> copy done" << std::endl; outfile << " -> copy done" << std::endl; if (!deletefile(partialresult)) dword err= getlasterror(); //error "error_file_not_found" }
has ideea happening here? thanks.
i have solved problem createfile marking them delete after process has finish this:
createfile(path, generic_read,file_share_delete,null, open_existing, file_flag_delete_on_close,null);
thank :)
Comments
Post a Comment