在程序中如何修改文件夹的名字
想在案程序中动态的去修改一个文件夹的名字,如何实现? --------------------编程问答-------------------- MoveFile(现名字, 新名字); --------------------编程问答-------------------- 多看API --------------------编程问答-------------------- MoveFileEx(from, to, MOVEFILE_REPLACE_EXISTING) --------------------编程问答-------------------- 纯粹的学习了。 --------------------编程问答-------------------- MoveFileThe MoveFile function moves an existing file or a directory, including its children.
To specify how to move the file, use the MoveFileEx function.
BOOL MoveFile(
LPCTSTR lpExistingFileName, // file name
LPCTSTR lpNewFileName // new file name
);
The MoveFile function will move (rename) either a file or a directory (including its children) either in the same directory or across directories. The one caveat is that the MoveFile function will fail on directory moves when the destination is on a different volume.
看看吧。。。。。。。。。。。。。。。。 --------------------编程问答-------------------- 学习了 --------------------编程问答-------------------- windows下 ,使用系统内置命令 ren
#include <string>
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
// 生成exe的相同目录下要有a.txt,执行之后更名为b.txt
// 设置命令
string filename="b.txt";
string cmd = "rename";
string src = "a.txt";
string cmds = cmd + " " + src +" " + filename;
// 执行命令: ren a.txt b.txt
system(cmds.c_str());
return 0;
}
--------------------编程问答--------------------
友情帮顶下!顺便学习学习!
补充:.NET技术 , VC.NET