且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何获取此文件夹中的文件夹列表?

更新时间:2022-05-25 17:27:49

如果不能使用.NET&托管代码,您可以通过win32 api的

If you can't use .NET & Managed code, you can go through the win32 api's

Here is an example that you can modify to only get Folders.

(基本上是下面的检查:)

(Basically the following check:)

...
  TCHAR szDir = _T("c:\\"); // or wherever.
  HANDLE hFind = FindFirstFile(szDir, &ffd);
...
  do {
      if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
      {
         // your code on 'ffd'
      }
  } while (FindNextFile(hFind, &ffd) != 0);