全部博文(788)
分类:
2009-02-11 16:54:28
procedure TForm1.Button1Click(Sender: TObject);
var
f: file of Byte;
size: Longint;
S: string;
y: Integer;
begin
if OpenDialog1.Execute then
begin
AssignFile(f, OpenDialog1.FileName);
Reset(f);
try
size := FileSize(f);
S := 'File size in bytes: ' + IntToStr(size);
y := 10;
Canvas.TextOut(5, y, S);
y := y + Canvas.TextHeight(S) + 5;
S := 'Seeking halfway into file...';
Canvas.TextOut(5, y, S);
y := y + Canvas.TextHeight(S) + 5;
Seek(f, size div 2);
S := 'Position is now ' + IntToStr(FilePos(f));
Canvas.TextOut(5, y, S);
finally
CloseFile(f);
end;
end;
end;
看看列子吧 估计你f定义的有问题
楼上的专赚大分!!
fuck你PP
var f:file of byte;
size:integer;
这是我的定义
你试着列子做做不就明白了?
关键要动手做啊
我写到一个新建的工程里就可以,加到我的工程里就报错
不知道有没有其他办法获取文件大小