以下这个程序能实现拷贝一个文件夹里的所以文件,但我只需拷贝最新的文件,如在 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();
}
源程序如下
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();
}
解决方案 »
- 为什么调用DPtoLP之前要先调用OnPrepareDC?
- 大家沒覺得csdn的帖子更新 延時變得很嚴重?
- First-chance exception in ***.exe(WINPORT.DLL):access violation的问题
- 字符串分割的问题
- Clistctrl控件能对一个单元格进行操作吗?比如添加,删除?
- 如何得到当前进程的进程句柄?
- 能否给个思路:关于如何做一个下旬系统!
- 关于在对话框里输出一个数组,恳求解答
- 谁能给一个例子说明如何利用installshield制作安装程序(发到我信箱)一定给加分!!
- 关于CMFCPropertyGridProperty中ComboBox下拉框问题
- VC++ 入门,请前辈指点!!
- assets进来啊
得到文件最后被写入的时间比较即可
得到文件最后被写入的时间比较即可
........................同意
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
);
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.