以下这个程序能实现拷贝一个文件夹里的所以文件,但我只需拷贝最新的文件,如在 2003 的文件夹下面  有很多数据库文件 如 s01m06.dbf(一月6号的意思)  s02m12.dbf  s06m12.dbf等 但我只要最新的。我用CFile::GetStatus( pFileName, status )这个函数好象不行。望指点。
  源程序如下
  void CFile_copyDlg::OnButton1() 
{
char * FromDirName="e:\\www\\2003";
char * ToDirName="e:\\caq\\";
CFileFind tempFind;
char tempFileFind[200];
sprintf(tempFileFind,"%s\\*.*",FromDirName);
BOOL IsFinded=(BOOL)tempFind.FindFile(tempFileFind);
while(IsFinded)
{
IsFinded=(BOOL)tempFind.FindNextFile();
if(!tempFind.IsDots())
{
char foundFileName[200];
strcpy(foundFileName,tempFind.GetFileName().GetBuffer(200));
if(tempFind.IsDirectory())
{
}
else
{
char tempFileName[200],ToFileName[200];
sprintf(tempFileName,"%s\\%s",FromDirName,foundFileName);
sprintf(ToFileName,"%s\\%s",ToDirName,foundFileName);
CopyFile(tempFileName,ToFileName,FALSE);
}
}
}
tempFind.Close();
}

解决方案 »

  1.   

    GetFileAttributesEx()
    得到文件最后被写入的时间比较即可
      

  2.   

    GetFileAttributesEx()
    得到文件最后被写入的时间比较即可
    ........................同意
      

  3.   

    明白了 不过有哪位高手能详细讲一下 GetFileAttributesEx()的用法。得到的属性怎么显示出来
      

  4.   

    HANDLE FindFirstFile(    LPCTSTR lpFileName, // pointer to name of file to search for  
        LPWIN32_FIND_DATA lpFindFileData  // pointer to returned information 
       );The WIN32_FIND_DATA structure describes a file found by the FindFirstFile or FindNextFile function. typedef struct _WIN32_FIND_DATA { // wfd  
        DWORD dwFileAttributes; 
        FILETIME ftCreationTime; 
        FILETIME ftLastAccessTime; 
        FILETIME ftLastWriteTime; 
        DWORD    nFileSizeHigh; 
        DWORD    nFileSizeLow; 
        DWORD    dwReserved0; 
        DWORD    dwReserved1; 
        TCHAR    cFileName[ MAX_PATH ]; 
        TCHAR    cAlternateFileName[ 14 ]; 
    } WIN32_FIND_DATA; FILETIME ftLastWriteTime; 就是建立时间。。The FileTimeToSystemTime function converts a 64-bit file time to system time format. BOOL FileTimeToSystemTime(    CONST FILETIME *lpFileTime, // pointer to file time to convert 
        LPSYSTEMTIME lpSystemTime  // pointer to structure to receive system time  
       );
      

  5.   

    GetFileAttributesExThe GetFileAttributesEx function retrieves attributes for a specified file or directory.
    BOOL GetFileAttributesEx(
      LPCTSTR lpFileName,
      GET_FILEEX_INFO_LEVELS fInfoLevelId,
      LPVOID lpFileInformation
    );Parameters
    lpFileName 
    [in] Pointer to a null-terminated string that specifies a file or directory. 
    In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming a File.
    Windows Me/98:  This string must not exceed MAX_PATH characters.
    fInfoLevelId 
    [in] Class of attribute information to retrieve. This parameter can be one of the following values. Value Meaning 
    GetFileExInfoStandard The lpFileInformation parameter is a WIN32_FILE_ATTRIBUTE_DATA structure. lpFileInformation 
    [out] Pointer to a buffer that receives the attribute information. The type of attribute information stored into this buffer is determined by the value of fInfoLevelId. 
    Return Values
    If the function succeeds, the return value is a nonzero value.If the function fails, the return value is zero. To get extended error information, call GetLastError.