简体   繁体   English

如何在Windows上的C ++中管理文件/目录的发现和使用?

[英]How to manage files/directories discovery and use in c++ on windows?

I'm stuck in terms of solutions for such thing. 我对这种事情的解决方案感到困惑。

ifstream infile;  
string STRING = "";  
string cdd = "PATH HERE";  
infile.open(cdd);  
while (!infile.eof())  
{  
getline(infile, STRING);  
}  

This is what I achieve through fstream library, and I find it fine, now the problem comes when I need to scan the directory(for files and directories) where the .exe is placed and obtain a list which I can iterate to find directories/files and which I use to pass the path string to cdd. 这是我通过fstream库实现的,并且发现还不错,现在问题出在我需要扫描放置.exe的目录(文件和目录)并获取列表时,可以迭代查找目录/文件,并将其用于将路径字符串传递给cdd。 I found different libraries such as , and , but because of the different types used in each library, I can't figure out how to nest functionalities that I need. 我发现了诸如和和的不同库,但是由于每个库中使用的类型不同,因此我无法弄清楚如何嵌套所需的功能。 If there is no way to nest such functionalities, someone can point to a 1 file only library that achieve such needed tasks? 如果没有嵌套此类功能的方法,那么有人可以指向实现此类所需任务的仅1个文件的库吗?

如果您的编译器支持C ++ 17,并且您可以/想要使用它,则可以使用C ++ 17一部分的文件系统

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM