用UltraEdit打开C:\diskinfo.sbj文件看到的是00 BC 61 4E,转换出十进制应该是12345678,怎样用字符串的方式读取出来'00BC614E'?????
var Cn_File:TextFile;
    s1:string;
begin
  AssignFile(Cn_file,'c:\diskinfo.sbj');
  Reset(cn_file);
  read(cn_file,s1);
  showmessage(s1);
end;为什么s1的值是空而不是'00BC614E'??????

解决方案 »

  1.   

    用TFileStream文件流操作,可以读出
      

  2.   

    用FileStream读出流,如果是字符流的话,可以用StringStream读出。
    但我看上面的十六进制,不大像是字符吧。
      

  3.   

    能否给个用Filestream读取的例子???????
      

  4.   

    program Project2;{$APPTYPE CONSOLE}uses
      SysUtils;var
      buf: array[0..3] of byte;
      f: Integer;
      i: integer;
    begin
      { TODO -oUser -cConsole Main : Insert code here }
      f:=FileOpen('1.txt', fmOpenRead);
      FileRead(f, buf, sizeof(buf));
      for i:=0 to 3 do
        Write(IntToHex(buf[i], 2), ' ');
      readln;
    end.
      

  5.   

    var fs:TFilestream;
      s1:string;
      myreader:TReader;
    begin 
      fs:=TFilestream.create('c:\diskinfo.sbj',fmopenread);
      myreader:=TReader.Create(fs,1024);
      myreader.ReadListBegin;
      s1:='';
      while not myreader.EndOfList do
      Begin
        s1:=s1+myreader.readstring;
      end;
      showmessage(s1);
      myreader.ReadListEnd;
      myreader.Free;
      fs.free;
    end;
    怎么出错啊???怎样读取00 BC 61 4E啊???????????
      

  6.   

    读取到array of byte 后,然后使用BinToHex
      

  7.   

    把'1.txt'换成你的'c:\diskinfo.sbj'不就可以了吗?
      

  8.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      buf: array[0..3] of byte;
      f: Integer;
      i: integer;
      s: string;
    begin
      s:='';
      f:=FileOpen('c:\diskinfo.sbj', fmOpenRead);
      FileRead(f, buf, sizeof(buf));
      FileClose(f);
      for i:=0 to 3 do
        s:=s+IntToHex(buf[i], 2);
      showmessage(s);
    end;