0

how to rename folder/file in c++

i've been working for a simple project called console file manager, can someone tell me in a simple way how to rename folder/files in c++?

25th Oct 2020, 3:52 PM
John Carlo Balubal
John Carlo Balubal - avatar
2 Respostas
+ 3
You seem to have posted a number of questions regarding file operations. Do you have access to a compiler implementing C++17 features, e.g. a recent GCC release? If so, you should try to familiarize yourself with the new C++ filesystem library. This documentation can help you: https://en.cppreference.com/w/cpp/filesystem More specifically to this problem, it implements a rename() function: https://en.cppreference.com/w/cpp/filesystem/rename If not, there is still the rename() function from C: https://en.cppreference.com/w/c/io/rename However, I am not sure if renaming directories is supported by the C version of the function.
25th Oct 2020, 4:06 PM
Shadow
Shadow - avatar
0
Use system function (It will run a command in CMD). system(ren "The File's Name" "Your new Name");
26th Oct 2020, 4:55 AM
Soheil
Soheil - avatar