苍 苍蝇拍子 Unregistered / Unconfirmed GUEST, unregistred user! 2004-01-06 #1 网络蚂蚁可以获得远端文件的大小,为了可以多线程下载,他事先在本地做了一个和远端一样大小的文件,问题:这个文件是用什么函数生成的,我查看了一下,里面为下载覆盖的区域都是00,哪位大侠知道,谢谢!
A andy263 Unregistered / Unconfirmed GUEST, unregistred user! 2004-01-06 #2 这个还用讨论吗? var antfile :file; data:array of byte; begin try assignfile(binfile,'filename'); reset(binfile,1); seek(binfile,0); setlength(data,大小); for i:=0 to 大小-1 do rdata:= 0; blockwrite(binfile,rdata,sizeof(rdata)); finally closefile(binfile); end;
这个还用讨论吗? var antfile :file; data:array of byte; begin try assignfile(binfile,'filename'); reset(binfile,1); seek(binfile,0); setlength(data,大小); for i:=0 to 大小-1 do rdata:= 0; blockwrite(binfile,rdata,sizeof(rdata)); finally closefile(binfile); end;
W wr960204 Unregistered / Unconfirmed GUEST, unregistred user! 2004-01-06 #3 procedure CreateFile(AFileName: string; ASize: Int64); const Tmp : Byte = 0; var FH : THandle; begin if FileExists(AFileName) then DeleteFile(AFileName); FH := FileCreate(AFileName); if fh = 0 then begin ShowMessage('创建失败'); Exit; end; try FileSeek(FH, ASize - SizeOf(Byte), 0); FileWrite(FH, Tmp, SizeOf(Byte)); finally FileClose(FH); end; end;
procedure CreateFile(AFileName: string; ASize: Int64); const Tmp : Byte = 0; var FH : THandle; begin if FileExists(AFileName) then DeleteFile(AFileName); FH := FileCreate(AFileName); if fh = 0 then begin ShowMessage('创建失败'); Exit; end; try FileSeek(FH, ASize - SizeOf(Byte), 0); FileWrite(FH, Tmp, SizeOf(Byte)); finally FileClose(FH); end; end;
苍 苍蝇拍子 Unregistered / Unconfirmed GUEST, unregistred user! 2004-01-07 #5 当时愚昧了,我已经做了基于SDK的测试类,100M仅需10秒,呵呵,不知道这个值还能否提高,好像蚂蚁要快点。