Delphi:BlockWrite I / O错误1784 [英] Delphi : BlockWrite I/O Error 1784

查看:52
本文介绍了Delphi:BlockWrite I / O错误1784的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用以下代码,我写了一个

With following code i write an

  dest : array of Bytes;

到文件。

  c: integer;
  size: integer;

如果我按字节进行操作:

If i do it Byte by Byte:

  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)。

everything works fine, but takes ages on large arrays (20MB biggest).

如果我尝试@@遇到I / O错误1784:

If i try to write it @ once i get I/O Error 1784:

  filename := ExePath + 'test.txt';
  AssignFile(myfile, filename);
  size := length(dest);
  ReWrite(myfile, size);
  BlockWrite(myfile, dest[0], size);
  CloseFile(myfile);

哪里可能出问题?
预先感谢。

Where is may fault? Thanks in advance.

推荐答案

知道了...

@我自己:RTFM

@ myself: RTFM

BlockWrite(myfile, dest[0], size);

必须是

BlockWrite(myfile, dest[0], 1);

因为已使用重写的方法将大小定义为数组的大小...。

cause size is defined already to the size of the array with rewrite....

filename := ExePath + 'test.txt';
AssignFile(myfile, filename);
size := length(dest);
ReWrite(myfile, size);
BlockWrite(myfile, dest[0], 1);   <-- 1 "dataset" of length (size) as defined before
CloseFile(myfile);

这篇关于Delphi:BlockWrite I / O错误1784的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆