gpt4 book ai didi

c++ - 如何在 C++ 中使用带通配符的 DeleteFile

转载 作者:塔克拉玛干 更新时间:2023-11-03 08:15:12 26 4
gpt4 key购买 nike

如何使用DeleteFile带通配符?

因此 c:\myFolder\a*.txt 将删除 a123.txta5555.txt 但不会删除 b123。文本文件

最佳答案

WIN32_FIND_DATAW fd;
HANDLE hFind = FindFirstFileW(L"C:\\myFolder\\a*.txt", &fd);
if (hFind != INVALID_HANDLE_VALUE)
{
do
{
DeleteFileW((wstring(L"C:\\myFolder\\") + fd.cFileName).c_str());
} while (FindNextFileW(hFind, &fd));
FindClose(hFind);
}

关于c++ - 如何在 C++ 中使用带通配符的 DeleteFile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32060534/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com