我很久没用Delphi了,你应该可以查Delphi的帮助,上面有例子。你找找看FileStream吧。
即使文件流不能解决你的问题,你也可以学习到一些流的知识。
在网络环境的开发中,流是最重要、最基础的知识。

解决方案 »

  1.   

    谢谢,问题是如何在流里查找字符串game呢
      

  2.   

    办法很多啊,用内存映射试试,查找用strpos函数
      

  3.   

    代码多了,但也不是太难,只要用到以下两个函数,自己查msdn吧
    CreateFileMapping,MapViewOfFile
      

  4.   

    var
      afile,bfile: file;
      filebuf: array of char;
      i, filelen: integer;
      
    begin
      assignfile(afile, '文件路径');
      reset(afile);
      filelen:= filesize(afile);
      setlength(filebuf, filelen);
      blockread(afile, filebuf, filelen);
      closefile(afile);
      i:=0;
      while i < filelen do
      begin
        if filebuf[i]='g' then
        begin
          inc(i);
          if filebuf[i]='a' then
          begin
            inc(i);
            if filebuf[i]='m' then
            begin
              inc(i);
              if filebuf[i]='e' then
              begin
                break;
              end else continue;
            end else continue;
          end else continue;
        end;
        inc(i);
      end;
      copy(filebuf,i-3,filelen);
      assignfile(bfile,  '文件路径');
      rewrite(bfile);
      blockwrite(bfile, filebuf, length(filebuf));
      closefile(bfile);
    end;