New topic: Deleting multiple file
<http://forums.realsoftware.com/viewtopic.php?t=45189> Page 1 of 1 [ 5 posts ] Previous topic | Next topic Author Message Rivo Post subject: Deleting multiple filePosted: Fri Aug 31, 2012 2:10 am Joined: Tue Aug 29, 2006 4:04 am Posts: 477 Location: Indonesia Hi, does anyone has some sample how to delete multiple in a single click with specific file extension ? the file name are based from listbox.text I have found in this forum, but I dont know how to modified it. Dim t as TextInputStream dim TextOut as textoutputstream dim f as new FolderItem dim p as string f = new folderitem f=getfolderitem("db.path") t=textinputstream.open(f) p=t.readline t.close Dim o as integer dim row as integer row =listbox2.listcount-1 'this is the number of rows if you start at 0 For o = 0 to row if RightB(f.item(o).name,4)=".odr" then f.item(o).delete msgbox str(f.Item(o))+" deleted" End Next any helps.?? thanks Regards, Rivo Top amitavak Post subject: Re: Deleting multiple filePosted: Fri Aug 31, 2012 4:12 am Joined: Mon Jan 02, 2012 1:51 am Posts: 262 Location: India I don't know if I understand your question properly. Is this like as a example, ListBox contains the file names when user click delete button it will delete all the files of specific extension(say .txt) listed in the listBox from a location(say Desktop). This is the code in the delete button action event. Dim fileName As String Dim file As FolderItem For i As Integer = 0 to Listbox1.ListCount - 1 fileName = Listbox1.Cell(i, 0) + ".txt" file = SpecialFolder.Desktop.Child(fileName) If file <> nil and file.Exists Then file.Delete MsgBox file.Name + " deleted" End If Next _________________ Amitava Real Studio 2011 Release 4 Windows 7 (32 bit) Top Rivo Post subject: Re: Deleting multiple filePosted: Fri Aug 31, 2012 5:07 am Joined: Tue Aug 29, 2006 4:04 am Posts: 477 Location: Indonesia yes, this is the one. thanks regards, Rivo Top markwalsh Post subject: Re: Deleting multiple filePosted: Fri Aug 31, 2012 7:26 am Joined: Wed May 20, 2009 4:43 pm Posts: 876 You can also do that with a single shell command (no loop) For Windows it would be Quote:DEL "C:\Path\To\Folder\*.odr" I'd have to check the command for Mac, I believe it's 'rm', but I don't know the exact usage. _________________ RB 2009r4 Windows XP Top Sky Stream Post subject: Re: Deleting multiple filePosted: Fri Aug 31, 2012 3:30 pm Joined: Sun Nov 23, 2008 12:27 am Posts: 337 Location: New Jersey markwalsh wrote:You can also do that with a single shell command (no loop) For Windows it would be Quote:DEL "C:\Path\To\Folder\*.odr" I'd have to check the command for Mac, I believe it's 'rm', but I don't know the exact usage. Though this would be faster... I would probably steer clear from this method unless I had other variables to confirm what I was deleting and was using for personal use If the user has a listbox of files that will be deleted.. the loop method would probably be best as the deletion process would be better controlled. Actually.. how I would approach it would be to store the information in a database and have records to show what was deleted. _________________ - Rich Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 5 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
