delphi 获取当前目录下的.txt文本不要带后缀扩展名


本文整理自网络,侵删。

 
/// 包含单元 uses FileCtrl
//获得文件列表
function GetAllTextFile(Path,fext: string): TStringList;
var
f: TSearchRec;
r: Integer;
begin
Result:=TStringList.Create;
if Path[Length(Path)]<>'\' then Path:=Path+'\';
r:=FindFirst(Path+fext, faAnyFile, f);
while r=0 do
begin
    Result.Append(f.Name);
    r:=FindNext(f)
end;
FindClose(f);
end;
//添加列表
procedure setlstbook(lst1:TListBox);
var
dir:string;
i,posx:integer;
filelst:TStringList;
begin
filelst:=TStringList.Create;
if SelectDirectory(Dir, [sdAllowCreate, sdPerformCreate, sdPrompt],1000) then
begin
    filelst.Text:=GetAllTextFile(Dir,'*.txt').Text;
   lst1.clear;
for i :=0 to filelst.Count-1 do
    begin
      posx:=Pos('.',filelstt.Strings[i]);
      lst1.Items.Add(copy(filelst.Strings[i],1,posx-1));
   end;
end;

相关阅读 >>

Delphi输入汉字自动产生拼音简码

Delphi 实现软件版验证码

Delphi 阿拉伯数字转中文汉字数字

Delphi2010 关于record类型rtti反射的用途和方法

Delphi 生成guid算法的单元

Delphi xe tbitmap支持gif,成为具有jpg,gif,bmp,ico,gif五种显示功能的图片控件

Delphi 获取系统注册的文件图标

Delphi firedac tfddatamove 导出csv

行为判断Delphi中窗体最大化与最小化事件

Delphi获取exe文件版本信息的函数

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...