|
发表于 2004-11-18 14:37:03
|
显示全部楼层
《第6章 虚拟文件系统》中的演示例子贴图1——虚拟文件系统搜索能力演示
程序6.4 搜索文件示例
procedure TMainForm.SearchFile;
var
lSearchParam: Business.System.TSearchFileParam;
lMathFileName: string;
lPath: string;
lFileList: TStringList;
lResultStr: string;
begin
lMathFileName := edtSearchName.Text;
lSearchParam.MatchFileName := lMathFileName;
lSearchParam.MatchCase := cbMatchCase.Checked;
lSearchParam.SearchSubPath := cbSearchSubPath.Checked;
if cbUseExpression.Checked then
begin
lSearchParam.MatchAttribute := edtMatchAttrib.Text;
lSearchParam.MatchIndex := edtMatchIndex.Text;
lSearchParam.MatchGUIDs := edtMatchGUIDs.Text;
end;
lPath := edtSearchPath.Text;
lFileList := TStringList.Create;
try
FileSys.FileSystem.SearchFile(lPath, lSearchParam, lFileList);
lbSearchResult.Items.Assign(lFileList);
if lFileList.Count > 0 then
lResultStr := SysUtils.Format('总共搜索到%d个符合条件的文件。', [lFileList.Count])
else
lResultStr := '没有搜索到任何符合条件的文件。';
StatusBar.SimpleText := lResultStr;
jsDialogs.ShowMsg(lResultStr, '')
finally
lFileList.Free;
end;
end;
|
|