获取文件夹下所有文件【MFC方法】

简介:

RT


#include <afxwin.h> // project->settings->general->Use MFC in a shared DLL

#include <iostream>
using namespace std;

void FindAllFile(CString path, CString* filenames, int& count)
{
	CFileFind finder;
	BOOL working = finder.FindFile(path + "\\*.*");
	while (working)
	{
		working = finder.FindNextFile();
		if (finder.IsDots())
			continue;
		if (finder.IsDirectory())
		{
			//FindAllFile(finder.GetFilePath(), filenames, count);
		} 
		else 
		{
			CString filename = finder.GetFileName();
			filenames[count++] = filename;
		}
	}
}

int main(int argc, char* argv[])
{
	CString filenames[1024];
	int count = 0;
	char path[MAX_PATH];
	while (cin >> path) { // . for current directory, empty for root directory
		FindAllFile(path, filenames, count);
		for (int i = 0; i < count; i++)
		{
			//cout << (LPCSTR)(filenames[i].GetBuffer(filenames[i].GetLength())) << endl;
			wcout << (LPCTSTR)filenames[i]<< endl;
		}
	}

	system("pause");
	return 0;
}



相关文章
|
1天前
win11查看文件/文件夹所使用的程序
win11查看文件/文件夹所使用的程序
5 0
|
2月前
|
C#
C# Winform 选择文件夹和选择文件
C# Winform 选择文件夹和选择文件
43 0
|
3月前
|
IDE API 开发工具
visual studio 生成dll文件以及修改输出dll文件名称操作
visual studio 生成dll文件以及修改输出dll文件名称操作
75 0
|
3月前
VBA实现当文件夹不存在时自动创建
VBA实现当文件夹不存在时自动创建
48 0
|
C# 图形学 C++
Unity与 DLL文件 ☀️| 怎样使用 C# 类库 生成一个DLL文件 并 调用!
📢前言 🎬生成DLL文件 🎥使用 C#类库 将Unity中的脚本打包成 DLL文件 并调用 🏳️‍🌈第一步:打开Visual Studio之后,新建一个项目 🏳️‍🌈第二步:选择类库(.NET Framework),改个名字,选择一个位置路径 🏳️‍🌈第三步:然后在创建的脚本中简单写一点代码,如下所示 🏳️‍🌈第四步:然后在解决方案资源管理器右键这个脚本 -> 添加 -> 引用 🏳️‍🌈第五步:然后点击浏览,找到Unity安装路径 -> Editor -> Data -> Managed 下的这两个DLL 文件,点击添加!
Unity与 DLL文件 ☀️| 怎样使用 C# 类库 生成一个DLL文件 并 调用!
MFC删除某个文件夹下的所有目录文件
1、该函数是删除文件夹下的所有文件 http://bbs.csdn.net/topics/390448664 BOOL CMainFrame::DeleteDirectory(con...
1799 0

热门文章

最新文章