realbasic-nug
[Top] [All Lists]

Re: FolderItem.delete Oddities?

To: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Subject: Re: FolderItem.delete Oddities?
From: Arnaud Nicolet <anic297@mac.com>
Date: Tue, 31 Mar 2009 20:27:36 +0200
Authentication-results: mx.google.com; spf=neutral (google.com: 74.124.194.228 is neither permitted nor denied by best guess record for domain of realbasic-nug-bounces@lists.realsoftware.com) smtp.mail=realbasic-nug-bounces@lists.realsoftware.com
Delivered-to: listarchive@realsoftware.com
In-reply-to: <54AD314E-9E2E-4CEA-A385-43BA49012837@bradrhine.com>
References: <E14D1190-E2BE-4E5A-BD5A-56B5ED3032EC@kimballlarsen.com> <54AD314E-9E2E-4CEA-A385-43BA49012837@bradrhine.com>
Reply-to: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Sender: realbasic-nug-bounces@lists.realsoftware.com

Le 31 mars 09 à 20:18, Brad Rhine a écrit :

On Mar 31, 2009, at 2:09 PM, Kimball Larsen wrote:

dim f as FolderItem = specialFolder.Temporary.child("ah")
dim f2 as folderItem
dim i as integer
for i = 1 to f.Count
  f2 = f.item(i)
  f2.Delete
next
f.delete

Change this:
  f2 = f.item(i)

To this:
  f2 = f.item(0)

Makes sense when you think about what the computer is actually doing.

But be prepared to handle cases where a file cannot be deleted (in that case, you skip it and increment the integer by 1).
However, it's simpler to use a backward loop:
for i=f.count downto 1

because, even if a file cannot be deleted, you skip it automatically (without even having to check if the file was successfully deleted).
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>