On Feb 24, 2007, at 9:08 PM, [EMAIL PROTECTED] wrote:
> On Feb 25, 2007, at 02:01 UTC, Lennox Jacob wrote:
>
>> Hello,
>> I have a Folder that is named "My Temp Files".
>> I also have a pushbutton named "Delete My Temp Files" How do I code
>> the pushbutton to delete all files in "My Temp Files" folder? Thanks.
>
> Well, I'm going to assume you can get a FolderItem to your My Temp
> Files folder. Then pass it into a method that looks like this:
>
> Sub DeleteFiles( dir as FolderItem )
> for i As Integer = dir.Count DownTo 1
> Dim f As File = dir.TrueItem(i)
> if f.Directory then DeleteFiles f
> f.Delete
> next
> End Sub
>
> This is a recursive implementation, which is not always ideal, but it
> sure is easy in cases like this. It's also light on error-checking...
> but hey, it's just sample code; you can't expect us to write your
> whole
> app for you. :)
I've got a recursive method that includes error-checking at <http://
www.declaresub.com/article/25/how-do-i-delete-a-folder>. Here's the
code.
Sub DeleteItem(f as FolderItem)
if f is nil then
return
end if
for i as Integer = f.Count downTo 1
DeleteItem f.TrueItem(i)
next
f.Delete
End Sub
------------------------
Charles Yeomans
http://www.declareSub.com/
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>