유돌이

calendar

1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31

Notice

2011. 7. 5. 13:08 델파이

function ReadUnicode(fName: String): WideString;
var
  F: File;
  FileSize, ReadSize: Cardinal;
  SearchRec: TSearchRec;
  Buffer: WideString;


begin
  FileSize:=0;
  if FindFirst(fName, faAnyFile, SearchRec)=0 then begin
    FileSize:=SearchRec.Size;
    FindClose(SearchRec);
  end;

 

  AssignFile(F, fName);
  SetLength(Buffer, FileSize);
  Reset(F, 1);
  BlockRead(F, PAnsiChar(Buffer)^, FileSize, ReadSize);

 

  Result:=Buffer;
  CloseFile(F);
end;

 

 

사용예

procedure TForm1.Button1Click(Sender: TObject);

const 파일경로 = 'C:\유니코드파일.dat';

var sList: TStringList;

begin

  sList:=TStringList.Create;

  try

    sList.Text:=ReadUnicode(파일경로);

    Memo1.Text:=sList.Text;

  finally

    FreeAndNil(sList);

  end;

end

posted by 유돌이