TIEPortableDevices.FindFilesByName
Declaration
function FindFilesByName(const sFolderID, sSearchText: WideString; GetTypes: TIEWPDObjectTypes = [iewFile, iewFolder]; iMaxDepth : Integer = 0): Boolean; overload;
function FindFilesByName(const sDeviceID, sFolderID, sSearchText: WideString; GetTypes: TIEWPDObjectTypes = [iewFile, iewFolder]; iMaxDepth : Integer = 0): Boolean; overload;
Description
Searches for files with the specified text and fill the
objects list.
Parameter | Description |
sDeviceID | The device to open (if not specified then the active device is used) |
sFolderID | The ID of a folder to search. Can be '' to search the whole device |
sSearchText | The text to search for, including wildcards. *TEXT* returns objects containing TEXT, TEXT* returns objects starting with TEXT, TEXT returns only objects with TEXT as their whole name |
GetTypes | They type of objects to returns, files (iewFile), folders (iewFolder) or both |
iMaxDepth | How many folders to search below the current folder, -1: Search all sub-folders, 0: Search only the specified folder, 1: Search the specified folder and the next level of sub-folders, etc. |
Result is false if an error was detected. You can check
LastError for detail on the failure.
Note: Searches are NOT case-sensitive. File objects are checked using the "FileName" property, folder objects are checked against their "FriendlyName"
// Return all files and folders in the current folder containing the word "Potato"
if FindFilesByName( sFolderID, '*potato*', [iewFile, iewFolder], 0 ) then
begin
lbxObjects.Items.Clear;
for I := 0 to fPortableDevices.ObjectCount - 1 do
lbxObjects.Items.Add( fPortableDevices.Objects[ I ].ID );
end;
// Return all files on the device of the exact filename "Image.jpg"
if FindFilesByName( sFolderID, 'Image.jpg' ) then
begin
lbxObjects.Items.Clear;
for I := 0 to fPortableDevices.ObjectCount - 1 do
lbxObjects.Items.Add( fPortableDevices.Objects[ I ].ID );
end;
// Return all folders that start with the word "Temp"
if FindFilesByName( sFolderID, 'Temp*', iewFolder ) then
begin
lbxObjects.Items.Clear;
for I := 0 to fPortableDevices.ObjectCount - 1 do
lbxObjects.Items.Add( fPortableDevices.Objects[ I ].ID );
end;