Renaming a file
-
I have two strings and I do the following...
string old_path; // this is like C:\\folder\\file.txt
string new_path; // this is like C:\\folder\\file1.txtrename(old_path_newpath)
Doing this I get the following error. How do I overcome this error.
error C2664: 'rename' : cannot convert parameter 1 from 'class std::basic_string,class std::allocator >' to 'const char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be calledTHANKS
-
I have two strings and I do the following...
string old_path; // this is like C:\\folder\\file.txt
string new_path; // this is like C:\\folder\\file1.txtrename(old_path_newpath)
Doing this I get the following error. How do I overcome this error.
error C2664: 'rename' : cannot convert parameter 1 from 'class std::basic_string,class std::allocator >' to 'const char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be calledTHANKS
try :- rename(old_path.c_str(), new_path.c_str() ); notice the c_str() - that effectively gives you a const char * from the string Im presuming rename(old_path_newpath) was a typo .. 'g'
-
I have two strings and I do the following...
string old_path; // this is like C:\\folder\\file.txt
string new_path; // this is like C:\\folder\\file1.txtrename(old_path_newpath)
Doing this I get the following error. How do I overcome this error.
error C2664: 'rename' : cannot convert parameter 1 from 'class std::basic_string,class std::allocator >' to 'const char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be calledTHANKS
Except this error you can use of SHFileOperation instead rename.
-
Except this error you can use of SHFileOperation instead rename.
if he cant figure out how to use a relatively simple API like rename(), do you honestly think he's going to be able to figure out SHFileOperation ? I dont think so ... (even I use a wrapper class around SHFileOperation to make it simpler) 'g'
-
if he cant figure out how to use a relatively simple API like rename(), do you honestly think he's going to be able to figure out SHFileOperation ? I dont think so ... (even I use a wrapper class around SHFileOperation to make it simpler) 'g'
No my answer was genraly SHFileOperation is better than rename not for solve problem.