使用TFileStream.Write(Buffer,Length)函数时Length不能大于1024,否则调用失败!
另外,动态数组也是这个问题:
rb:array of Byte;SetLength(rb,Length);//Length也不能大于1024请高手指点,万分感谢!

解决方案 »

  1.   

    Following a call to SetLength, S is guaranteed to reference a unique string or array梩hat is, a string or array with a reference count of one. If there is not enough memory available to reallocate the variable, SetLength raises an EOutOfMemory exception.
      

  2.   

    outer2000(天外流星) :
    Length为longint,当设置大于1024时并不发异常:
    TFileStream不执行Write
    而数组只对前1024个进行操作
      

  3.   

    TFileStream.Write 最後是調用 api WriteFile, 
    好象沒有這個限制
      

  4.   

    halfdream(哈欠) :TFileStream.Write(Buf,Len)是一个函数,返回的是一个longint型的值,值为向文件中实际写入的字节数,当我写入的LEN>1024时返回为0!
      

  5.   

    楼主是怎么写的。。
    就这样应该没有问题procedure TForm1.Button1Click(Sender: TObject);
    var
      buf:array of byte;
      fo:TFileStream;
      n:integer;
    begin
      setlength(buf,2000);
      fo:=TFileStream.Create('d:\a.txt',fmCreate);
      n:=fo.Write(buf,2000);
      fo.Free;
      ShowMessage(intToStr(n));
    end;
      

  6.   

    halfdream(哈欠) :
      你的程序我试过了,可以,最大能为6K,
    但跟踪BUF时,只能看到1024的内容,可能是只显示1024吧?另外,写到文件中的是乱码,不知怎么回事?为了不忘记结贴,先给大家加分,谢谢了!
      

  7.   

    呵呵..乱码是因为我没有给BUF里面填东西啊..setlength(buf,2000);//只是分配内存,不会自动填充...