On Wednesday, February 27, 2002, at 09:26 PM, Mike Tuller wrote:
I am trying to create an app the will list files by file type that are
located on a volume. I this case, all applications. I am a little confused
as to how I should go about this. Here is what I have so far.
Dim i As Integer
Dim apps As FolderItem
apps = GetFolderItem( "Macintosh HD")
For i = 1 to apps.count
if apps.item(i).MacType="APPL" then
ListBox1.addrow apps.item(i).name
else
end
next
As you guessed, that will only find applications listed in the top level
of the volume. The easiest way to search through all the sub folders is
with recursion, which is a technique where a function will call itself.
For example:
Sub SearchVolume( F As Folderitem )
Dim i, Count As Integer
Dim File As Folderitem
Count = F.Count
for i = 1 to Count
File = F.TrueItem(i) // prevent infinite loop due to circular aliases
if File<>Nil and File.Exists
if File.Directory then // its a folder, search it
SearchVolume( File )
elseif File.MacType="APPL" then
ListBox1.addrow File.DisplayName
end if
end if
next
-Noah Desch
|