Win32 API,用于在C中重命名文件 [英] Win32 API for rename a file in C

查看:538
本文介绍了Win32 API,用于在C中重命名文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果是源目录和目标目录,MoveFile实际上会将源文件复制到目标文件中,这意味着我最终将看到两个文件.

If the source directory and the target directory, MoveFile would actually make a copy of the source file into the target file, which means that I will end up seeing two files.

这是实现重命名的最佳方法吗?

Is that the best way that rename can be achieved?

推荐答案

MoveFile 函数确实是您想要的.从文档中:

The MoveFile function is indeed what you want. From the documentation:

MoveFile 函数将在同一目录或跨目录中移动(重命名)文件或目录(包括其子级).

The MoveFile function will move (rename) either a file or a directory (including its children) either in the same directory or across directories.

如果源位置和目标位置都在同一卷上,则将执行原子重命名操作.如果它们位于不同的卷上,那么将执行复制/删除操作(这是您最好的操作).

If the source and destination locations are both on the same volume, then an atomic rename operation is performed. If they're on different volumes, then a copy/delete operation is done instead (this is the best you can do).

这篇关于Win32 API,用于在C中重命名文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆