重命名包含文件的目录结构中的中间文件夹 [英] Rename a middle folder within a directory structure containing files

查看:76
本文介绍了重命名包含文件的目录结构中的中间文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Visual Studio 2015.编程unicode characterset& MFC。所以我正在使用CStrings ... ect



我有一个非常长的目录结构,文件位于其中。我需要更改结构中一个文件夹的名称。示例如下:



旧名称:F:\ folder1 \ folder1 \ folder3 \ folder4 \ backups \ JumpList 1 \ folder A \。 ..files

\ folder B \ ...文件



新名称:F:\ folder1 \ folder1 \ folder3 \ folder4 \ backups \ JumpList 2 \ folder \ ...文件



注1:文件夹从JumpList 1变为 JumpList 2。其他一切都保持不变。在文件夹JumpList中有两个文件夹,都包含文件。



我尝试过:



我还没有为这个特定任务尝试任何事情,因为它只是整个项目的一小部分,但是,我担心没有简单的方法可以做到这一点。这意味着使用CFindFile,FindFirst,FindNext,RemoveDirectory,CreateDirectory等等,有很多暴力。

Using Visual studio 2015. Programming unicode characterset & MFC. So I'm using CStrings... ect

I have a very long directory structure where files are located. I need to change the name of one folder within the structure. Example below:

Old name: F:\folder1\folder1\folder3\folder4\backups\JumpList 1\folder A\...files
\folder B\...files

New Name: F:\folder1\folder1\folder3\folder4\backups\JumpList 2\folder\...files

Note 1 : The folder is changing from "JumpList 1" to "JumpList 2". Everything else stays the same. In folder JumpList there are two folders, both containing files.

What I have tried:

I have not tried anything yet for this specific tasks as it is a small part of the entire project, however, my fear is that there is no simple way to do this. That means using CFindFile, FindFirst, FindNext, RemoveDirectory, CreateDirectory .. ect, with a lot of brute force.

推荐答案

我想看看你想要的文件夹作为IShellItem,并使用IFileOperation接口执行重命名。获取这些接口的实例需要一些阅读才能加快速度,但由于它将在所有文件操作中赋予您灵活性,因此非常值得付出努力。
I'd look at getting the folder you want as an IShellItem, and using the IFileOperation interface to perform the rename. It will take a bit of reading to get up to speed on getting instances of these interfaces, but it would be well worth the effort due to the flexibility it will grant you in all file operations.


这篇关于重命名包含文件的目录结构中的中间文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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