close

int DeviceConfig::GetFolderCount(CString target_folder)

{

     int count = -1;                      //檔案的counter

     TCHAR szDir[128];               //要讀取的資料夾的位址。

     WIN32_FIND_DATA FileData;       //指著目前讀取到的File的指標。

     HANDLE hList;                   //指著要讀取的資料夾的指標。

     _stprintf_s(szDir, _T("%ws\\*"), target_folder);

     if ((hList = FindFirstFile((LPCWSTR)szDir, &FileData)) == INVALID_HANDLE_VALUE)

         cout << "No directories be found." << endl << endl;

     else {

         while (1) {

              if (!FindNextFile(hList, &FileData)) {

                  if (GetLastError() == ERROR_NO_MORE_FILES)

                       break;

              }

              count++;

         }

     }

     FindClose(hList);

     return count;

}

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 Eric 的頭像
    Eric

    一個小小工程師的心情抒發天地

    Eric 發表在 痞客邦 留言(0) 人氣()