var F: TextFile;
S: string;
begin
if OpenDialog1.Execute then { Display Open dialog box }
begin
AssignFile(F, OpenDialog1.FileName); { File selected in dialog }
Reset(F);
Readln(F, S); { Read first line of file }
Edit1.Text := S; { Put string in a TEdit control }
CloseFile(F);
end;
end;
S: string;
begin
if OpenDialog1.Execute then { Display Open dialog box }
begin
AssignFile(F, OpenDialog1.FileName); { File selected in dialog }
Reset(F);
Readln(F, S); { Read first line of file }
Edit1.Text := S; { Put string in a TEdit control }
CloseFile(F);
end;
end;
解决方案 »
- URL启动delphi应用程序获取启动参数?
- delphi怎样连接Sqlite
- 请问如何判断双击的是DBGRID的标题还是DBGRID中的一行?
- 有关两个form传递值的问题 。。。在线等~~
- 100分急求:怎么提取treeview当前目录下子节点的值
- 谁能提供一个RSA或3Des或md5的加密算法?非常感谢 up有分
- 我有DELPHI7 DEVELOPER'S GUIDE 有谁要吗?
- 怎样使ListView的某个结点不可见?
- 请教:delphi中怎样在一个exe文件中启动另外的一个exe文件!!
- 请COM专家指教
- 请问如何在Form中加入flash动画?
- 如何将DBGrid中的数据打印出来!!!急急急!!!
BackupName: string;
FileHandle: Integer;
StringLen: Integer;
X: Integer;
Y: Integer;
begin
if SaveDialog1.Execute then
begin
if FileExists(SaveDialog1.FileName) then
begin
BackupName := ExtractFileName(SaveDialog1.FileName);
BackupName := ChangeFileExt(BackupName, '.BAK');
if not RenameFile(SaveDialog1.FileName, BackupName) then raise Exception.Create('Unable to create backup file.');
end;
FileHandle := FileCreate(SaveDialog1.FileName);
{ Write out the number of rows and columns in the grid. }
FileWrite(FileHandle,
StringGrid1.ColCount, SizeOf(StringGrid1.ColCount));
FileWrite(FileHandle,
StringGrid1.RowCount, SizeOf(StringGrid1.RowCount));
for X := 0 to StringGrid1.ColCount ?1 do
begin for Y := 0 to StringGrid1.RowCount ?1 do
begin
{ Write out the length of each string, followed by the string itself. }
StringLen := Length(StringGrid1.Cells[X,Y]);
FileWrite(FileHandle, StringLen, SizeOf(StringLen));
FileWrite(FileHandle,
StringGrid1.Cells[X,Y], Length(StringGrid1.Cells[X,Y]);
end;
end;
FileClose(FileHandle);
end;end;
var
F: TextFile;
begin
AssignFile(F, 'C:\a.txt');
Rewrite(F);
Writeln(F, 'Just created file with this text in it...');
CloseFile(F);
end;
end.
var
s:TStringList;
path:String;
begin
path:=ExtractFilePath(Application.ExeName );
s:=TStringList.Create ;
s.LoadFromFile(path + '\a.txt');
s.Strings[0]:='000';
s.Strings[s.Count-1]:='555';
s.SaveToFile(path + '\a.txt');
s.Free ;
end;
s:TStringList;
begin
s:=TStringList.Create ;
s.LoadFromFile('c:\a.txt');
s.Strings[0]:='000';
s.Strings[1]:='111';
s.SaveToFile('c:\a.txt');
s.Free ;
end;
memo1.lines.savetofile()