【问题标题】:How can I rename files of which I don't know the extension?如何重命名我不知道扩展名的文件?
【发布时间】:2013-02-12 16:36:09
【问题描述】:

我有一个包含这些文件的目录:

one.txt
two.mp3
three.bmp

有没有办法使用MoveFile() 重命名文件但不指定文件的扩展名(所有文件都有不同的文件名)?

如果不是,当我只知道

one
two
three

?

【问题讨论】:

    标签: c++ windows rename


    【解决方案1】:

    一旦您知道前缀,就读取目录的文件列表并找到具有该前缀的有效文件名,并将该文件名与函数一起使用。

    【讨论】:

      【解决方案2】:

      您必须使用底层操作系统 API 来扫描目录中的文件并将每个文件名与您想要的前缀进行比较。 Here is another question that shows you how to list the contents of a directory in Windows.

      【讨论】:

        猜你喜欢
        • 2021-01-14
        • 2018-01-11
        • 1970-01-01
        • 2010-11-16
        • 1970-01-01
        • 2019-01-06
        • 2014-05-29
        • 2016-12-06
        • 2018-10-17
        相关资源
        最近更新 更多