Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Wed Nov 14, 2018 10:43 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Deleting multiple file
PostPosted: Fri Aug 31, 2012 2:10 am 
Offline

Joined: Tue Aug 29, 2006 4:04 am
Posts: 513
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
 Profile  
Reply with quote  
 Post subject: Re: Deleting multiple file
PostPosted: Fri Aug 31, 2012 4:12 am 
Offline
User avatar

Joined: Mon Jan 02, 2012 1:51 am
Posts: 382
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 Karan
Real Studio 2012 Release 1
Windows 7 (32 bit)
Mac OS X Version 10.7


Top
 Profile  
Reply with quote  
 Post subject: Re: Deleting multiple file
PostPosted: Fri Aug 31, 2012 5:07 am 
Offline

Joined: Tue Aug 29, 2006 4:04 am
Posts: 513
Location: Indonesia
yes,
this is the one.


thanks


regards,
Rivo


Top
 Profile  
Reply with quote  
 Post subject: Re: Deleting multiple file
PostPosted: Fri Aug 31, 2012 7:26 am 
Offline

Joined: Wed May 20, 2009 4:43 pm
Posts: 958
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
 Profile  
Reply with quote  
 Post subject: Re: Deleting multiple file
PostPosted: Fri Aug 31, 2012 3:30 pm 
Offline

Joined: Sun Nov 23, 2008 12:27 am
Posts: 404
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.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group