텍스트 파일 경로를 넣으면 텍스트내용이 반환.
functionReadUnicode(fName: String): WideString;
var
F: File;
FileSize, ReadSize: Cardinal;
SearchRec: TSearchRec;
Buffer: WideString;
begin
FileSize:=0;
ifFindFirst(fName, faAnyFile, SearchRec)=0then 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;
사용예
procedureTForm1.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;
댓글 없음:
댓글 쓰기