用正常的文件复制,复制完成后再用API:SetFileTime修改文件的属性<br><br>引用以前的帖子:<br>type<br> TFileTimeType = (fttCreation, fttLastAccess, fttLastWrite);<br> //分别对应文件创建时间,访问时间,修改时间<br>function GetFileDateTime(const FileName: string; FileTimeType: TFileTimeType): TDateTime;<br>var<br> Handle: THandle;<br> FindData: TWin32FindData;<br> LocalFileTime: TFileTime;<br> DosDateTime: Integer;<br>begin<br> Handle := FindFirstFile(PChar(FileName), FindData);<br> if Handle <> INVALID_HANDLE_VALUE then<br> begin<br> Windows.FindClose(Handle);<br> if (FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = 0 then<br> begin<br> case FileTimeType of<br> fttCreation:<br> FileTimeToLocalFileTime(FindData.ftCreationTime, LocalFileTime);<br> fttLastAccess:<br> FileTimeToLocalFileTime(FindData.ftLastAccessTime, LocalFileTime);<br> fttLastWrite:<br> FileTimeToLocalFileTime(FindData.ftLastWriteTime, LocalFileTime);<br> end;<br> if FileTimeToDosDateTime(LocalFileTime, LongRec(DosDateTime).Hi,<br> LongRec(DosDateTime).Lo) then <br> begin<br> Result := FileDateToDateTime(DosDateTime);<br> Exit;<br> end;<br> end;<br> end;<br> Result := -1;<br>end;<br><br>function SetFileDateTime(const FileName: string; FileTimeType: TFileTimeType; DateTime: TDateTime): Integer;<br>var<br> Handle: THandle;<br> LocalFileTime, FileTime: TFileTime;<br> DosDateTime: Integer;<br> I : TFileTimeType;<br> FileTimes: array[TFileTimeType] of Pointer;<br>begin<br> Result := 0;<br> DosDateTime := DateTimeToFileDate(DateTime);<br> Handle := FileOpen(FileName, fmOpenWrite or fmShareDenyNone);<br> if Handle <> INVALID_HANDLE_VALUE then<br> try<br> for I := fttCreation to fttLastWrite do<br> FileTimes := nil;<br> DosDateTimeToFileTime(LongRec(DosDateTime).Hi, LongRec(DosDateTime).Lo, LocalFileTime);<br> LocalFileTimeToFileTime(LocalFileTime, FileTime);<br> FileTimes[FileTimeType] := @FileTime;<br> if SetFileTime(Handle, FileTimes[fttCreation], FileTimes[fttLastAccess],<br> FileTimes[fttLastWrite]) then Exit;<br> finally<br> FileClose(Handle);<br> end;<br> Result := GetLastError;<br>end;<br>使用举例:<br>1、获取文件创建时间:<br> ShowMessage(DateTimeToStr(GetFileDateTime('c:/key.txt',fttLastWrite)));<br>2、设置文件修改时间:<br> SetFileDateTime('c:/key.txt',fttLastWrite, StrToDateTime('2000/01/01'));