var
   DyamicArray,DyamicArrayPartOne,DyamicArrayWholeFile: array of byte;  if OpenDialog1.Execute then
  begin
    AssignFile(f, OpenDialog1.FileName);
Reset(f,1);//这里抱错:[Error] Unit1.pas(110): Too many actual parameters
//如果我改成Reset(f);的话,可以运行,但是DyamicArrayPartOne,这个里面全是0,我觉得应该是文件里的内容才是.
 BlockRead(f,DyamicArrayPartOne,Sizeof(DyamicArrayPartOne));

解决方案 »

  1.   

    我查了帮助,说用1是表示记录大小是1,不定义的话将是128,这个到也无所谓,
    那如何解释DyamicArrayPartOne读了文件后全为零呢?
    前提条件在读前,我已经        SetLength(DyamicArrayPartOne,512);了,
      

  2.   

    你多看看文本操作吧,楼主是第一天学Delphi吗?
      

  3.   

    那如何解释DyamicArrayPartOne读了文件后全为零呢?
    前提条件在读前,我已经        SetLength(DyamicArrayPartOne,512);了,
    BlockRead(f,DyamicArrayPartOne,Sizeof(DyamicArrayPartOne));》》你知道Sizeof(DyamicArrayPartOne) 等于多少吗?就是四字节,他是一指针,你改为512看看
      

  4.   

    你的程序也有问题改为:
    var
      DyamicArrayPartOne: array of byte;
      f: file;
      num: integer;
    begin
      if OpenDialog1.Execute then
      begin
        AssignFile(f, OpenDialog1.FileName);
        Reset(f);
        try
          SetLength(DyamicArrayPartOne, 512);
          BlockRead(f,Pointer(DyamicArrayPartOne)^,512,num);//前提是文件有多大,我们一般设此值为<=文件大小
        finally
          closefile(f);
        end;
      end;
    end;
      

  5.   

    谢谢各位,我刚丛c++转过来的,见笑了,
    1 我操作的不是文本文件,
    2看来是参数类型不对:Pointer(DyamicArrayPartOne)^,3那Reset(f);//不要1 这个怎么说啊?
    帮助:
    procedure Reset(var F [: File; RecSize: Word ] );
    If F is an untyped file, RecSize specifies the record size to be used in data transfers. If RecSize is omitted, a default record size of 128 bytes is assumed.
    我这里使用的不是文本文件,我把他们都默认成无类型文件操作,应该可以吧?
    如果可以,那我指明记录大小应该是可以的吧?Reset(f,1); 但结果为什么不行呢????????????
      

  6.   

    关于第3点,Reset(f);我还不是很理解,望解答
      

  7.   

    AssignFile:分配一个文件名给TextFile变量。Reset(f):打开一个文件进行读操作。ReWrite(f):打开一个文件进行写操作,抹去前面的内容。BlockRead:从文件读入数据。其它的你可以参考帮助文件。
      

  8.   

    procedure Reset(var F [: File; RecSize: Word ] );F is a variable of any file type associated with an external file using AssignFile. RecSize is an optional expression, which can be specified only if F is an untyped file. If F is an untyped file, RecSize specifies the record size to be used in data transfers. If RecSize is omitted, a default record size of 128 bytes is assumed.好好看看吧,你会知道你想要的
      

  9.   

    F is a variable of any file type associated with an external file using AssignFile. RecSize is an optional expression, which can be specified only if F is an untyped file. If F is an untyped file, RecSize specifies the record size to be used in data transfers. If RecSize is omitted, a default record size of 128 bytes is assumed.仅F是无类型文件,RecSize 是个可选的。如果F是无类型文件,RecSize 被定为记录的大小且被用于数据传输时,如果RecSize 被省掉,那默认的文件大小为128个字节。
    在我的程序里F是无类型文件。那么为什么仍不可以使用RecSize 这个参数呢?
    Reset(f);可以

    Reset(f,1);不可以
      

  10.   

    楼上的不是不可以使用,实在是你的程序写错了,见这句:
    BlockRead(f,DyamicArrayPartOne,Sizeof(DyamicArrayPartOne));
    我给你改写的你看了吗?晕
    var
      DyamicArrayPartOne: array of byte;
      f: file;
      num: integer;
    begin
      if OpenDialog1.Execute then
      begin
        AssignFile(f, OpenDialog1.FileName);
        Reset(f); //Reset(f,1);也是可以的
        try
          SetLength(DyamicArrayPartOne, 512);
          BlockRead(f,Pointer(DyamicArrayPartOne)^,512,num);//前提是文件有多大,我们一般设此值为<=文件大小
        finally
          closefile(f);
        end;
      end;
    end;总的说来Reset(f,1);没有太大的意义,只是规定了一次传输块的大小,而BlockRead函数是要读取多少字节如512,并不是只读取一次,读取的字节数是由它的参数以及文件大小共同控制的。也许我说的还不太规范,呵呵