I am new to C++ development and i have written a program to rename a file in a directory, while build no errors and no print messages in the console while execution and the filename was not renamed.
Please find below my code and let me know, if you require any additional information to provide a solution.
using namespace std;
namespace fs = boost::filesystem;
int main(int argc, char *argv)
cout << "There are " << argc << " arguments:" << endl;
for (int nArg=0; nArg < argc; nArg++)
cout << nArg << " " << argv[nArg] << endl;
platform = ( platform == "Win32" || platform == "Win64" || platform == "Cygwin" ) ? "Windows" : "POSIX";
cout << "Platform is " << platform << endl;
string epub_filename = filepath.filename();
string epub_dirname = filepath.parent_path().string();
string zip_filename = filepath.stem() + ".zip";
fs::rename(filepath, epub_dirname + "/" + zip_filename);
cout << epub_filename << endl;
cout << epub_dirname << endl;
cout << zip_filename << endl;
argv Input: D:\epub\test.epub
10:16:55 **** Rebuild of configuration Debug for project Argc ****
Info: Internal Builder is used for build
g++ "-IC:\\Libraries\\boost_1_42_0" -O0 -g3 -Wall -c -fmessage-length=0 -o "src\\Argc.o" "..\\src\\Argc.cpp"
g++ "-LC:\\Libraries\\boost_1_42_0\\stage\\lib" -o Argc.exe "src\\Argc.o" -lboost_system-mgw47-1_42 -lboost_filesystem-mgw47-mt-d-1_42
10:16:58 Build Finished (took 3s.743ms)
console: <terminated> Arc.exe [C/C++ Application] D:\Argc\Debug\Argc.exe
Also, i have written a simple program using boost::filesystem to create a new directory - No errors in the program but no new directory in the location.
Thanks in Advance
Last edited on
Ok, you are using mingw4.7 and boost 1.42 and I'm using mingw 4.6 and boost 1.47 - I had to adjust a couple of lines- but it basically worked for me.
I did make sure that the file to be renamed was in a directory that I had read/write access.
Thank you for your support.
I have fixed the issue by replacing the file boost_system-mgw47-1_42 with boost_system-mgw47-mt-d-1_42 as it is a debug build.