隨着下面的代碼我寫一個的Delphi:塊寫入I/O錯誤1784
dest : array of Bytes;
到文件中。
c: integer;
size: integer;
如果我去做了逐字節:
filename := ExePath + 'test.txt';
AssignFile(myfile, filename);
ReWrite(myfile, 1);
Write the data array to the file
for c := 0 to length(dest) - 1 do
BlockWrite(myfile, dest[c], 1);
CloseFile(myfile);
一切工作正常,但需要大陣列(最大20MB)年齡。
如果我嘗試寫@一旦我得到的I/O錯誤1784:
filename := ExePath + 'test.txt';
AssignFile(myfile, filename);
size := length(dest);
ReWrite(myfile, size);
BlockWrite(myfile, dest[0], size);
CloseFile(myfile);
哪裏可能的錯嗎? 在此先感謝。
恕我直言txt不是最好的exten除非你在一個字節數組中存儲文本,這不是最好的容器。 – jachguate
請發佈您收到的確切錯誤消息。 '1784'是操作系統錯誤,而不是I/O錯誤(請參閱http://docwiki.embarcadero.com/RADStudio/XE3/en/Delphi_Runtime_Errors)。如果你向我們展示了'ExePath'的位置以及'myfile'是如何聲明的,那將會很有幫助。 –
什麼是myfile的sdatatype(聲明)? –