1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| #include<cstdio> #include<cstring> #include<iostream> #include<windows.h>
#define MAXN 100005
using namespace std;
void surf(WIN32_FIND_DATA myData) { cout<<myData.ftCreationTime.dwLowDateTime<<endl; cout<<myData.ftLastAccessTime.dwLowDateTime<<endl; cout<<myData.ftLastWriteTime.dwLowDateTime<<endl; SYSTEMTIME ctime , atime , wtime; FileTimeToSystemTime(&myData.ftCreationTime , &ctime); FileTimeToSystemTime(&myData.ftLastAccessTime , &atime); FileTimeToSystemTime(&myData.ftLastWriteTime , &wtime); printf("%d年%d月%d日%d时%d分%d秒\n" , ctime.wYear , ctime.wMonth , ctime.wDay , ctime.wHour , ctime.wMinute , ctime.wSecond); printf("%d年%d月%d日%d时%d分%d秒\n" , atime.wYear , atime.wMonth , atime.wDay , atime.wHour , atime.wMinute , atime.wSecond); printf("%d年%d月%d日%d时%d分%d秒\n" , wtime.wYear , wtime.wMonth , wtime.wDay , wtime.wHour , wtime.wMinute , wtime.wSecond); cout<<endl<<endl; }
void traverse(char *Str) { WIN32_FIND_DATA myData; HANDLE hFind = INVALID_HANDLE_VALUE; char str[MAX_PATH] = {0}; strcpy(str , Str); strcat(str , "/*"); hFind = FindFirstFile(str , &myData); if(INVALID_HANDLE_VALUE == hFind) return ; while(FindNextFile(hFind , &myData)) { if(myData.cFileName[0] != '.') { cout<<"========="<<myData.cFileName<<"=========="<<endl; surf(myData); if(myData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY) { char dir[MAX_PATH] = {0}; snprintf(dir , MAX_PATH, "%s/%s" , Str , myData.cFileName); traverse(dir); } } } FindClose(hFind); }
int main() { char *str = "./test"; traverse(str); }
|