// Norway.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include <stdio.h> #include <string> #include <vector> #include <windows.h> using namespace std; typedef vector<win32_find_data> tFoundFilesVector; std::string LastWriteTime; //int getFileList(wstring filespec, tFoundFilesVector &foundFiles) //uni int getFileList(const char * filespec, tFoundFilesVector &foundFiles) //ansi { WIN32_FIND_DATA findData; HANDLE h; int validResult=true; int numFoundFiles = 0; //h = FindFirstFile(filespec.c_str(), &findData); //uni h = FindFirstFile((LPCSTR)filespec, &findData); //ansi if (h == INVALID_HANDLE_VALUE) return 0; while (validResult) { numFoundFiles++; foundFiles.push_back(findData); validResult = FindNextFile(h, &findData); } FindClose(h); return numFoundFiles; } ULONGLONG GetFileSizeEx( CString strPath ) { WIN32_FIND_DATA FindData = { 0 }; //gets a file search handle HANDLE hFirstFile = FindFirstFile( strPath, &FindData ); //if the handle is valid if( hFirstFile != INVALID_HANDLE_VALUE ) { //closes the file search handle FindClose( hFirstFile ); ULONGLONG FileSize = FindData.nFileSizeHigh; FileSize <<= sizeof( FindData.nFileSizeHigh ) * 8; // Push by count of bits FileSize |= FindData.nFileSizeLow; return FileSize; } return 0; // File not found } void showFileAge(tFoundFilesVector &fileList) { unsigned _int64 fileTime, curTime, age; tFoundFilesVector::iterator iter; FILETIME ftNow; CoFileTimeNow(&ftNow); curTime = ((_int64) ftNow.dwHighDateTime << 32) + ftNow.dwLowDateTime; for (iter=fileList.begin(); iter<filelist.end();> { fileTime = ((_int64)iter->ftLastWriteTime.dwHighDateTime << 32) + iter->ftLastWriteTime.dwLowDateTime; age = curTime - fileTime; if (age <= (_int64)100000000UL) { rename(string("c:\\Mapper\\").append(string(iter->cFileName)).c_str(), "c:\\FAIL\\myfile.txt"); wcout << " Delete: '" <<endl; wcout << "FILE: '" << iter->cFileName << "', AGE: " << (_int64)age/10000000UL << " seconds" << endl; remove ("c:\\FAIL\\myfile.txt"); //remove(string("c:\\mapper\\").append(string(iter->cFileName)).c_str()); MessageBox(HWND_DESKTOP,"Text here","No Text here",MB_OK); } else { wcout << " Quit: '" <<endl; wcout << "FILE: '" << iter->cFileName << "', AGE: " << (_int64)age/10000000UL << " seconds" << endl; //return; } } } int main() { string fileSpec = "*.*"; tFoundFilesVector foundFiles; tFoundFilesVector::iterator iter; int foundCount = 0; getFileList("c:\\Mapper\\*.txt", foundFiles); getFileList("c:\\Mapper\\*.jpg", foundFiles); foundCount = foundFiles.size(); if (foundCount) { wcout << "Found "<<foundCount<<" matching files.\n"; showFileAge(foundFiles); } system("pause"); return 0; }</win32_find_data></windows.h></vector></string></stdio.h></iostream>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)