delphi 下的读写文件

zerohero 2003-04-14 07:03:51
pascal的读写文件命令(write,read)好像只能在delphi中的控制台程序中使用,如果是Applation程序要读写文件,该怎么做?
...全文
75 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
coreblood 2003-06-21
  • 打赏
  • 举报
回复
var
Filel:Tstrings

begin
Filel:=Tstringlist.create;
Filel.loadFromFile('c:\text.txt');

showmessage(File.strings[0]);

Filel.savetoFile('*****.txt');

Filel.Free;
end;
buzuidaoke 2003-06-21
  • 打赏
  • 举报
回复
fuzhan820 2003-06-21
  • 打赏
  • 举报
回复
thanks
swayi21 2003-04-14
  • 打赏
  • 举报
回复
var
TxtFile: TextFile;
StrTemp: string;

AssignFile(TxtFile,'D:\YU\Yu.Yu');
Reset(TxtFile);
Readln(TxtFile, StrTemp);
CloseFile(TxtFile);


AssignFile(TxtFile,'D:\YU\Yu.Yu');
Rewrite(TxtFile);
Writeln(TxtFile, StrTemp);
CloseFile(TxtFile);
ahjoe 2003-04-14
  • 打赏
  • 举报
回复
用TFileStream也很方便
Taken 2003-04-14
  • 打赏
  • 举报
回复
书上介绍的和楼上说的一样的

不过我习惯用TStringList的LoadFromFile和SaveToFile方法
bluebilly 2003-04-14
  • 打赏
  • 举报
回复
var
t: textfile;
s: string[100];
begin
Assignfile(T, 'example.txt');
Reset(t);
readln(t, s);
showMessage(s);
closeFile(t);
end;

5,388

社区成员

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

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