首页 > 解决方案 > 删除名称中包含单词的文件。C++

问题描述

有没有办法删除名称中包含一个单词的任何文件?例如:chrome.1323.pf 我想删除任何名称中包含 chrome 的文件。我试过这个:

if (GetAsyncKeyState(0x75)) {

            std::string command = "del /Q ";
            std::string path = "C:\\Windows\\Prefetch\\AUDIOZ.*.pf";
            system(command.append(path).c_str());
        } 

但它并没有真正运作良好..

标签: c++

解决方案


您可以在要删除的文件名中提供通配符:

std::string command = "del /Q C:\\temp\\chrome*";
system(command);

推荐阅读