Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6630111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:21:22+00:00 2026-05-25T22:21:22+00:00

Deep in the sauce here. I haven’t worked with time to much so I’m

  • 0

Deep in the sauce here. I haven’t worked with time to much so I’m a little confused here. I know there is FILETIME and SYSTEMTIME. What I am trying to get at this point (because it might change) are file that are less than a 20 seconds old. This returning the files and their size and something in seconds, What I’d like to know is where it is filtering by time if it is, and how can I adjust it to suit my needs. Thank you.

using namespace std;
typedef vector<WIN32_FIND_DATA> tFoundFilesVector;
std::wstring LastWriteTime;  
int getFileList(wstring filespec, tFoundFilesVector &foundFiles)
{
    WIN32_FIND_DATA findData;
    HANDLE h;
    int validResult=true;

    int numFoundFiles = 0;
    h = FindFirstFile(filespec.c_str(), &findData);

    if (h == INVALID_HANDLE_VALUE)
        return 0;

    while (validResult)
    {
        numFoundFiles++;
        foundFiles.push_back(findData);
        validResult = FindNextFile(h, &findData);
    }
    return numFoundFiles;
}

void showFileAge(tFoundFilesVector &fileList)
{
    unsigned _int64 fileTime, curTime, age;
    tFoundFilesVector::iterator iter;
    FILETIME ftNow;
    //__int64 nFileSize;
          //LARGE_INTEGER li;    
    //li.LowPart = ftNow.dwLowDateTime;
    //li.HighPart = ftNow.dwHighDateTime;

    CoFileTimeNow(&ftNow);
          curTime = ((_int64) ftNow.dwHighDateTime << 32) + ftNow.dwLowDateTime;

          for (iter=fileList.begin(); iter<fileList.end(); iter++)
    {
        fileTime = ((_int64)iter->ftLastWriteTime.dwHighDateTime << 32) + iter->ftLastWriteTime.dwLowDateTime;

        age = curTime - fileTime;

        cout << "FILE: '" << iter->cFileName << "', AGE: " << (_int64)age/10000000UL << "  seconds" << endl;
    }
}

int main()
{
    string fileSpec = "*.*";
    tFoundFilesVector foundFiles;
    tFoundFilesVector::iterator iter;

    int foundCount = 0;

    getFileList(L"c:\\Mapper\\*.txt", foundFiles);
    getFileList(L"c:\\Mapper\\*.jpg", foundFiles);

    foundCount = foundFiles.size();
    if (foundCount)
    {
        cout << "Found "<<foundCount<<" matching files.\n";
        showFileAge(foundFiles);
    }
    system("pause");
    return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:21:23+00:00Added an answer on May 25, 2026 at 10:21 pm

    I don’t know what you’ve done to try to debug this but your code doesn’t work at all. The reason is you’re passing getFileList() a wstring but then passing that to the ANSI version of FindFirstFile(). Unless you #define UNICODE or use the appropriate compiler option, all system calls will expect char *, not UNICODE.

    The easiest fix is to simply change the declaration of getFileList() to this:

    int getFileList(const char * filespec, tFoundFilesVector &foundFiles)
    

    Change the call to FindFirstFile() to this:

    h = FindFirstFile((LPCSTR)filespec, &findData);
    

    And then change the calls to it to this:

    getFileList("c:\\Mapper\\*.txt", foundFiles);
    getFileList("c:\\Mapper\\*.jpg", foundFiles);
    

    Your other option is to switch all char strings to wide chars, but either way you need to be consistent throughout. Once you do that the program works as expected.

    As for your final question, your program is not filtering by time at all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm way in deep water here trying to get ahold of a vc. My
I have a rather deep hierarchy of objects that I'm trying to persist with
I don't have deep knowledge of assembly programming . I am trying to translate
I know of a Deep Cloning library in Java, which I use in my
First post here: -Deep Breath- In order to 'windowise' an app that works pretty
I have some code that performs a deep copy using Object.clone, but I'm trying
I'm trying to make a deep copy of a generic list, and am wondering
Is there a way to deep clone JSoup Document object and get back exactly
Deep dive on the Magento internals here, not looking for a solution to a
Is there any way to create a deep copy of a canvas element with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.