不会很慢吧......你看看是比较慢还是写数据库慢啊
我测试读取文件的时间,system32文件夹下2000多文件全读出来只需要400毫秒
再读另一个并且比较估计也不会超过1秒种
而写数据库.......2000多条数据写数据库也不是很慢啊......就算写一条post一条也只用了10秒左右......如果全写完一次post应该用不了几秒种的
我的读文件测试代码:
procedure GetFileDateTime(const FileName: string; var t1,t2,t3:TDateTime);
function FTtoDT(FileTime: TFileTime):TDateTime;
var
DosDateTime: Integer;
begin
if FileTimeToDosDateTime(FileTime, LongRec(DosDateTime).Hi,
LongRec(DosDateTime).Lo) then
result:=FileDateToDateTime(DosDateTime)
else
result:=-1;
end;
var
Handle: THandle;
FindData: TWin32FindData;
LocalFileTime: TFileTime;
begin
Handle := FindFirstFile(PChar(FileName), FindData);
if Handle <> INVALID_HANDLE_VALUE then
begin
Windows.FindClose(Handle);
if (FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = 0 then
begin
FileTimeToLocalFileTime(FindData.ftCreationTime, LocalFileTime);
t1:=FTtoDT(LocalFileTime);
FileTimeToLocalFileTime(FindData.ftLastAccessTime, LocalFileTime);
t2:=FTtoDT(LocalFileTime);
FileTimeToLocalFileTime(FindData.ftLastWriteTime, LocalFileTime);
t3:=FTtoDT(LocalFileTime);
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
SRec:TSearchRec;
path:string;
t1,t2,t3:TDateTime;
t:cardinal;
begin
path:='C:/WINDOWS/system32/';
ListView1.Items.Clear;
t:=gettickcount;
ListView1.Items.BeginUpdate;
if FindFirst(path+'*.*',faAnyFile,SRec)=0 then
repeat
If (srec.Attr and FILE_ATTRIBUTE_DIRECTORY)<>0 Then //文件
continue;
GetFileDateTime(path+srec.Name,t1,t2,t3);
with ListView1.Items.Add do
begin
Caption:=datetimetostr(t1);
SubItems.Add(datetimetostr(t2));
SubItems.Add(datetimetostr(t3));
end;
until FindNext( SRec )<>0;
ListView1.Items.EndUpdate;
panel1.Caption:=inttostr(listview1.Items.Count)+' - '+inttostr(gettickcount-t);
end;