var F: TextFile; AssignFile(F, OpenDialog1.FileName); { File selected in dialog box } Reset(F); Readln(F, S); { Read the first line out of the file } Edit1.Text := S; { Put string in a TEdit control } CloseFile(F);
使用流来打开读写文件, TFileStream.Create('文件名',fmOpenReadWrite or fmShareDenyNone)
AssignFile(F, OpenDialog1.FileName); { File selected in dialog box }
Reset(F);
Readln(F, S); { Read the first line out of the file }
Edit1.Text := S; { Put string in a TEdit control }
CloseFile(F);