【问题标题】:Searching Directories "backwards" using windows API in C++ [duplicate]在 C++ 中使用 Windows API“向后”搜索目录 [重复]
【发布时间】:2012-07-02 08:05:29
【问题描述】:

可能重复:
How to get the parent directory of the current folder in a C program?

我正在使用 C++ Windows API,并在最初给定特定目录路径(即 C:\...\ProjectXX)的情况下查找文件夹和目录。我特别使用了 FindFirstFile() 和 FindNextFile() 函数。但是,有时我想在目录中“向后”移动,即获取给定目录的“父级”(包含给定目录的文件夹)。这在什么情况下是可能的,在什么功能下使用?

【问题讨论】:

  • 听起来更像是向上而不是向后 (Z->A)。

标签: c++ windows directory


【解决方案1】:

与 C 不同,C++ 有一个方法:.remove_leaf()。但是你没有使用 C++ 函数,你使用的是 WinAPI 函数,所以PathRemoveFileSpec() 会更合适。

【讨论】:

    猜你喜欢
    • 2011-09-26
    • 2016-08-12
    • 2016-12-01
    • 2021-01-20
    • 2022-01-02
    • 1970-01-01
    • 2010-12-27
    • 1970-01-01
    • 2014-10-07
    相关资源
    最近更新 更多