Settings | Sign in | Sign up

There is currently 1 post.

【方法】在指定文件夹中搜索文件

Floor 1 巨大八爪鱼 3/25/16 21:40
【程序】
#include "stdafx.h"
#include <Windows.h>

#define echo(str) WriteConsole(hConsoleOutput, str, _tcslen(str), NULL, NULL)
#define echo_t(str) echo(TEXT(str))

int _tmain(int argc, _TCHAR* argv[])
{
    LPTSTR szFileName = TEXT("D:\\Codes\\PHP\\Arslanbar\\2\\classes\\*t.*");
    WIN32_FIND_DATA ffd;
    HANDLE hFindFile = FindFirstFile(szFileName, &ffd);
    HANDLE hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
    if (hFindFile == INVALID_HANDLE_VALUE)
    {
        echo_t("No file");
    }
    else
    {
        do
        {
            echo(ffd.cFileName);
            echo_t("\r\n");
        } while (FindNextFile(hFindFile, &ffd));
        FindClose(hFindFile);
    }
    return 0;
}

【输出】
DataObject.php
DataObject.php.LCK
Request.php
ZhSupport.php
Press any key to continue . . .

Content converter:

Reply the post
Content:
User: You are currently anonymous.
Captcha:
Unclear? Try another one.
©2010-2025 Purasbar Ver3.0 [Mobile] [Desktop]
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported license.