------------------------ Charles Yeomans http://www.declareSub.com/
On Feb 26, 2007, at 2:11 PM, Tim Jones wrote: > > On Feb 25, 2007, at 9:18 AM, Charles Yeomans wrote: > >> On Feb 24, 2007, at 9:08 PM, [EMAIL PROTECTED] wrote: >> >> 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 > > Here's a sure way (warning to shell haters - involves shell and > sudo...) > > Prompt user for admin password: > > Dim sh As New Shell > > Sh.Execute "echo " + thePassword + " | sudo -S /usr/bin/true" > Sh.execute "sudo rm -rf " + f.ShellPath > Sh.Execute "sudo -K" > > This would use your same f folderitem. By doing the first sudo call, > the potential for someone ca[turing the password is reduced to near > nil. The last sudo -K just resets / clears the sudo timer. I don't think this is necessarily more sure. How does it handle a change of directory contents during execution? Charles Yeomans _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html>
