本文整理自网络,侵删。
var D: TOpenTextFileDialog; S: TStringList;begin D := TOpenTextFileDialog.Create(nil); try D.Title := 'Import from File'; D.Filter := 'Text File|*.txt|All Files|*';
if D.Execute then begin S := TStringList.Create; try S.LoadFromFile(D.FileName, D.Encodings.Objects[D.EncodingIndex] as TEncoding);
M.SelText := S.Text; finally S.Free; end; end;
finally D.Free; end;
相关阅读 >>
Delphi 操作 pdf -- 使用 acrobat sdk 初探
Delphi xe2获取文件的 md5、crc、sha-1、sha-256、sha-512
Delphi 从paintbox拷贝一部分内容到tbitmap
更多相关阅读请进入《Delphi》频道 >>