題目為:button1.Click創建一個E:\one.txt 文件, 然後往其中按順序加入'a', 'b', 'c'
也就是說: 不管button1 click多少次, one.txt中的內容始終為:
a
b
c===================================================================
我寫了如下, 不知道錯在哪了,它說:I/O error 32. 哪位高手能給我一個正確的完善的程序, 多謝了!
FileCreate ('E:\one.txt');
AssignFile (f, 'E:\one.txt');
append (f);
writeln(f, 'a');
writeln(f, 'b');
writeln(f, 'c');
也就是說: 不管button1 click多少次, one.txt中的內容始終為:
a
b
c===================================================================
我寫了如下, 不知道錯在哪了,它說:I/O error 32. 哪位高手能給我一個正確的完善的程序, 多謝了!
FileCreate ('E:\one.txt');
AssignFile (f, 'E:\one.txt');
append (f);
writeln(f, 'a');
writeln(f, 'b');
writeln(f, 'c');
f: System.Text;
begin
AssignFile(f, 'c:\temp\one.txt');
Rewrite(f);
Writeln(f, 'a');
Writeln(f, 'b');
Writeln(f, 'c');
CloseFile(f);
end;
我是使用FileCreate 函數來創建的。
然後button2.Click中再用一個循環往這些文本文檔中寫數據所以在我的系統中必須要先創建文本文檔,然後獲得局柄,再寫值,
而不好每一個文件都先有局柄,再創建, 所以你給的方法我不好用. :)看看我的代碼:為什麼會有錯?
FileCreate ('E:\one.txt');
AssignFile (f, 'E:\one.txt');
append (f);
writeln(f, 'a');
writeln(f, 'b');
writeln(f, 'c');
f:TextFile;
begin
AssignFile (f, 'E:\one.txt');
Rewrite(f);
Writeln(f, 'a');
Writeln(f, 'b');
Writeln(f, 'c');
CloseFile(f);
var
f: TextFile;
begin
FileClose(FileCreate('c:\temp\one.txt'));
AssignFile(f, 'c:\temp\one.txt');
Append(f);
Writeln(f, 'a');
Writeln(f, 'b');
Writeln(f, 'c');
Flush(f);
CloseFile(f);
end;
写的是正确的