如何修改文本里面的内容

aloking 2005-03-17 11:57:44
一个文本文件
123456789
2afasfsas
3asdfsdfa
4asdfsadf
5aaaaaaaa
6asdasdas
7asdsadsa
8asdasdas
9asdasdas
我要输入一串字符替换第5行的aaaaaaaa
如何操作?
...全文
138 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
jinjazz 2005-03-17
  • 打赏
  • 举报
回复
memo1.Lines[4]:=stringreplace(memo1.Lines[4],'a','aaaaa',[rfReplaceAll]);
sunshinell 2005-03-17
  • 打赏
  • 举报
回复
期待ing~~~帮顶
liangyong007a 2005-03-17
  • 打赏
  • 举报
回复
AssignPrn procedure

//ssigns a text file variable to the printer.

AssignPrn procedure

//ssigns a text file variable to the printer.
/
Eoln function

//Tests whether the file pointer is at the end of a line.

Erase procedure

//Deletes an external file.

Flush function

//Empties the buffer of a text file opened for output.

Read procedure

//Read reads data from a file.

ReadLn procedure

//Reads a line of text from a file.

SeekEof function

//Returns the end-of-file status of a file, ignoring whitespace.

SeekEoln function

//Returns the end-of-line status of a file, ignoring whitespace.

SetLineBreakStyle procedure

//Determines the end-of-line and end-of-file conventions for text file I/O.

SetTextBuf procedure

//Assigns an I/O buffer to a text file.

Write procedure (for text files)

//Writes to a text file.

WriteLn procedure

//Writes to a text file and adds an end-of-line marker.
liangyong007a 2005-03-17
  • 打赏
  • 举报
回复
用系统自带的textfile的一些方法去操作吧
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;
aloking 2005-03-17
  • 打赏
  • 举报
回复
var
sl:TStringList;
s:string;
begin
sl:=TStringList.Create;
try
sl.loadfromfile('youfilename');
s:=sl.strings[linenum];
{
}
finally
sl.free;
end;
end;
有没有更好的方法,直接定位过去啊
aloking 2005-03-17
  • 打赏
  • 举报
回复
文本文件比较大,用memo 不太好吧,有没有直接操作文本文件的

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧