procedure TForm1.GetFileList1(AStrings: TStrings; ASourFile: string);
var
sour_path,sour_file: string;
TmpList:TStringList;
FileRec:TSearchrec;
begin sour_path:=ExtractFilePath(ASourFile);
sour_file:=ExtractFileName(ASourFile); if not DirectoryExists(sour_path) then
begin
AStrings.Clear;
exit;
end; TmpList:=TStringList.Create;
TmpList.Clear; if FindFirst(sour_path+sour_file,faAnyfile,FileRec) = 0 then
repeat
if ((FileRec.Attr and faDirectory) = 0) then
begin
TmpList.Add(sour_path+FileRec.Name)
end;
until FindNext(FileRec)<>0; SysUtils.FindClose(FileRec); AStrings.Assign(TmpList); TmpList.Free;
label3.Caption:=sour_path;
label2.Caption:=sour_FILE;end;调用代码
procedure TForm1.Button6Click(Sender: TObject);
var
path2:string;
begin
path2:=PATH+'*.tif';
edit1.Text:=path2;
GetFileList1(ListBox1.items,'F:\123\*.TIF');end;问题:在调用GETFILELIST1时,如果'F:\123\*.TIF'换成path2,则提取不到文件路径,为什么?
var
sour_path,sour_file: string;
TmpList:TStringList;
FileRec:TSearchrec;
begin sour_path:=ExtractFilePath(ASourFile);
sour_file:=ExtractFileName(ASourFile); if not DirectoryExists(sour_path) then
begin
AStrings.Clear;
exit;
end; TmpList:=TStringList.Create;
TmpList.Clear; if FindFirst(sour_path+sour_file,faAnyfile,FileRec) = 0 then
repeat
if ((FileRec.Attr and faDirectory) = 0) then
begin
TmpList.Add(sour_path+FileRec.Name)
end;
until FindNext(FileRec)<>0; SysUtils.FindClose(FileRec); AStrings.Assign(TmpList); TmpList.Free;
label3.Caption:=sour_path;
label2.Caption:=sour_FILE;end;调用代码
procedure TForm1.Button6Click(Sender: TObject);
var
path2:string;
begin
path2:=PATH+'*.tif';
edit1.Text:=path2;
GetFileList1(ListBox1.items,'F:\123\*.TIF');end;问题:在调用GETFILELIST1时,如果'F:\123\*.TIF'换成path2,则提取不到文件路径,为什么?
解决方案 »
- 大家在使用的数据编辑类第三方控件有哪些?
- 新手问题,高手请进
- 用Delphi如何做网上自动投票功能。
- 大家都来讨论一下吧!!!好奇怪的问题呀!!!!
- 怎样取得默认参数的值,有谁知道?
- 这样写错了吗??
- 大家给看看一个报表的问题!
- delphi处理paradox表它们支持临时表吗?
- 在线等待:1:如何从TDateTime中提取出年份,月份,号数??2:如何比较两个TDateTime类型的次序,比如怎样才知道2002-6-1在2002-6-4的前面??
- 如何将一段加密,可是仍能看到原来的字,但不能复制
- delphi 程序运行着一段时间之后出现 存放体空间不足 无法处理此命令 怎么回事?
- SkinPack以及themeengine 控件有谁用过?
GetFileList1(ListBox1.items,'F:\123\*.TIF');
GetFileList1(ListBox1.items,path2);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
调用GetFileList1(ListBox1.items,path2)前,showmessage(path2)看看你的path2是什么?估计是少个\
直接跳转了!郁闷
procedure TForm1.GetFileList1(AStrings: TStrings; ASourFile: string);
var sour_path,sour_file: string;
TmpList:TStringList;
FileRec:TSearchrec;
begin
sour_path:=ExtractFilePath(ASourFile);
sour_file:=ExtractFileName(ASourFile);
if not DirectoryExists(sour_path) then begin
AStrings.Clear;
exit;
end;
TmpList:=TStringList.Create;
TmpList.Clear;
if FindFirst(sour_path+sour_file,faAnyfile,FileRec) = 0 then
repeat
if ((FileRec.Attr and faDirectory) = 0) then begin
TmpList.Add(sour_path+FileRec.Name)
end;
until FindNext(FileRec)<>0;
SysUtils.FindClose(FileRec);
AStrings.Assign(TmpList);
TmpList.Free;
end;
procedure TForm1.Button1Click(Sender: TObject);
var path2,PATH:string;
begin
if OpenDialog1.Execute then begin
PATH:=ExtractFilePath(OpenDialog1.FileName);
path2:=PATH+'*.rar';
GetFileList1(ListBox1.items,path2);
end;
end;
path:=ExtractFilePath(Application.ExeName);
if SelectDirectory( ' ', ' ',Path) then
begin
if path[length(path)] <> '\' then path:=path+ '\';
Edit1.Text:=path;
end;
我用的API开的文件夹,结果多了一个空格,奇怪的是TRIM也没用!谢谢大家