assignfile 是什么函數(shù) delphi
發(fā)布時(shí)間:2025-08-21 | 來源:互聯(lián)網(wǎng)轉(zhuǎn)載和整理
參考實(shí)例:
var
f: textfile; // 聲明文本文件類型變量
begin
assignfile(f, 'c:myfile.txt');
end;
// 將c:myfile.txt文件與f變量建立連接,后面可以使用f變量對(duì)文件進(jìn)行操作。
將外部一個(gè)文件名 c:1.txt ,以變量的形式關(guān)聯(lián),如
const
cnsfilename='c:1.txt';
var
f:text;// 以文本的形式,也可以以其他形式。
方民十很任門共打白況究復(fù)院。
begin
是可多起從只長求基農(nóng)己教花安千團(tuán)稱。
assignfile(f,cnsfilename);
try
if fileexists(cnsfilename) then
append(f)
else
rewrite(f);
writeln(f,'hellow world.');
finally
closefile(f);
end;
end;
鏈接一個(gè)文件,看幫助,寫的那么清楚你不看
delphi(pascal) code 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;