又改了一下,这回能指定要建文件的大小了(以字节为单位,不过不是很准认真看一下就会明白为什么,不要系只是做坏事不是吗?)和追加文件块的大小(以字节为单位且是128的倍数),修正了原来硬盘满后会出错的BUG(就是用了(Num<>nBlockNum来实现的),指定文件大小的关键是i*128*nBlockNum>=nFileSize这一句.;加入了命令行支持功能.<br><br>program BigFile;<br>uses SysUtils;<br>procedure CreateSilFile(FileName:String;nFileSize:Longint=38400;nBlockNum:Integer=300;nSleepTime:Integer=0);<br>var<br> UnTypedFile:file;<br> i:Longint;<br> Num:Integer;<br>begin<br> i:=0;<br> assignfile(UnTypedFile,FileName);<br> Rewrite(UnTypedFile);<br> try<br> repeat<br> Try<br> BlockWrite(UnTypedFile,[0..128],nBlockNum,Num);<br> i:=i+1;<br> except<br> end;<br> if nSleepTime<>0 then<br> Sleep(nSleepTime);<br> until (i*128*nBlockNum>=nFileSize) or (Num<>nBlockNum);<br> finally<br> CloseFile(UnTypedFile);<br> end;<br>end;<br><br>begin<br> if ParamStr(4)<>'' then CreateSilFile(ParamStr(1),StrToInt64(ParamStr(2)),StrToInt(ParamStr(3)),StrToInt(ParamStr(4)))<br> else<br> if ParamStr(3)<>'' then<br> CreateSilFile(ParamStr(1),StrToInt64(ParamStr(2)),StrToInt(ParamStr(3)))<br> else<br> if ParamStr(2)<>'' then<br> CreateSilFile(ParamStr(1),StrToInt64(ParamStr(2)))<br> else<br> if ParamStr(1)<>'' then<br> CreateSilFile(ParamStr(1))<br> else<br> CreateSilFile('C:/300.txt',30000000,300,50);<br>end.<br>