如何查找距离当前时间最近创建的文件,文件的扩展名以当前日期命名,例myfile.20050114
今天的文件就是myfile.20090120,每天一个文件,若某一天没有生成此文件,就要查找最后一次生成的文件是哪一个,找到读取该文件
再有就是把某日期之前的文件都删除怎么办?
谢谢!

解决方案 »

  1.   

    只能遍历了,取文件时间BOOL GetFileTime(
      HANDLE hFile,                 // handle to file
      LPFILETIME lpCreationTime,    // creation time
      LPFILETIME lpLastAccessTime,  // last access time
      LPFILETIME lpLastWriteTime    // last write time
    );
      

  2.   

    如果 myfile.20050120 不存在,就找 myfile.20050119,18,17……好像很容易。
      

  3.   

    BOOL bFind;
    char filename[MAX_PATH];\
    memset(filename,0x00,sizeof(MAX_PATH));
    strcpy(filename,"myfile.*");
    CFileFind finder;
    bFind = finder.FindFile(filename);
    while(bFind==TRUE)
    {
    bFind=finder.FindNextFile();
    strcpy(filename,finder.GetFileName());
    char* pdest;
    pdest=strchr(filename,".");
    strcpy(filname,pdest+1);
    //得出今天的时间,比如是"20050120"
    strcpy(timestr,"20050120");
    if(strcmp(filename,timestr)==0)
    {
    ……
    }
    }
    finder.close();