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;

相关阅读 >>

datasnap 上传/下载大文件(本demo以图传片文件为例)

Delphi xe7 android通过配置实现splash功能

Delphi将目录删除到回收站中

Delphi内存映射 与 映射数据获取

Delphi 清除windows 图标缓存源代码

Delphi 文件夹重命名

Delphi 获取程序自身大小的函数

Delphi 获取标题栏高

Delphi 几个实用的html解析函数

Delphi侦测条码枪方式

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



打赏

取消

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

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

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

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

评论

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