F
fridaydream
Unregistered / Unconfirmed
GUEST, unregistred user!
type
TMyUser=Record
MyName:String[10];
end;
var
MyUser:TMyUser;
MyFileStream:TFileStream;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
MyFileStream:=TFileStream.Create('myfile',fmOpenWrite);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
MyFileStream.Free;
end;
procedure TForm1.btnReadClick(Sender: TObject);
var
readsum:integer;
begin
MyFileStream.Seek(100,0);
ReadSum:=MyFileStream.Read(MyUser,Sizeof(TMyUser));
//就是上面这句的Read()始终读不入数据。
//ReadSum始终为0!
//文件'myfile'里面是有数据的
//不知怎么回事?
//求教了
//thx!!!
edtRead.Text:=MyUser.MyName;
edtsum.Text:=InttoStr(ReadSum);
edtPosition.Text:=InttoStr(Myfilestream.Position);
end;
end.
TMyUser=Record
MyName:String[10];
end;
var
MyUser:TMyUser;
MyFileStream:TFileStream;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
MyFileStream:=TFileStream.Create('myfile',fmOpenWrite);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
MyFileStream.Free;
end;
procedure TForm1.btnReadClick(Sender: TObject);
var
readsum:integer;
begin
MyFileStream.Seek(100,0);
ReadSum:=MyFileStream.Read(MyUser,Sizeof(TMyUser));
//就是上面这句的Read()始终读不入数据。
//ReadSum始终为0!
//文件'myfile'里面是有数据的
//不知怎么回事?
//求教了
//thx!!!
edtRead.Text:=MyUser.MyName;
edtsum.Text:=InttoStr(ReadSum);
edtPosition.Text:=InttoStr(Myfilestream.Position);
end;
end.