在C ++中重命名文件 [英] Renaming a File in C++
本文介绍了在C ++中重命名文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想重命名文件,但是我正在获取文件,但是很难重命名它.这是我的代码.
I want to rename a file and I am getting the file, but having a hard time renaming it. Here is my code.
rename(string("c:\\Users\\DS\\Downloads\\").append(string(iter->cFileName)).c_str()myfile.txt);
推荐答案
所有人都告诉我们您的问题是什么,请不要让我们来解决.
您缺少在myfile.txt
之前缺少逗号(,
)的情况,并且需要将myfile.txt
括在双撇号("
)
First of all tell us what your problem is, do not leave it to us to figure out.
You''re missing a missing a comma (,
) beforemyfile.txt
and you need to enclosemyfile.txt
in double apostrophes ("
)
中编译.必须为int rename ( const char * oldname, const char * newname );
, http://www.cplusplus.com/reference/clibrary/cstdio/rename/ [ ^ ].分别计算两个文件名,然后传递给函数.
—SA
It won''t compile. Must beint rename ( const char * oldname, const char * newname );
, http://www.cplusplus.com/reference/clibrary/cstdio/rename/[^]. Calculate two file names separately and pass to the function.
—SA
这篇关于在C ++中重命名文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文