Real Software Forums
http://forums.realsoftware.com/

Deleting file based from a listbox data
http://forums.realsoftware.com/viewtopic.php?f=10&t=47667
Page 1 of 1

Author:  Rivo [ Sun Apr 21, 2013 11:19 pm ]
Post subject:  Deleting file based from a listbox data

Hi,

I have a code to delete the file which is based from listbox data,

Dim fileName As String
Dim file,filex As FolderItem
dim f as folderitem
dim t as textinputstream
dim p as string
f=getfolderitem("//data/")
t=textinputstream.open(f)
p=t.readline
t.close

For i As Integer = 0 to Listbox7.ListCount - 1
file = getfolderitem(p).child("data").child(Listbox7.Cell(i, 2) +".odr")
filex = getfolderitem(p).child("data").child(Listbox7.Cell(i, 2) +".done")

If file <> nil and file.Exists Then
file.CopyFileTo filex
End If

If file <> nil and file.Exists Then
if Listbox7.cell(i,0)<>tgl.text then
file.Delete
end if
End If
next



before was running when I put the code

If file <> nil and file.Exists Then
file.Delete
end if
End If
next

I dunno why it wont remove the file anymore since I put this line to monitoring the date.
if Listbox7.cell(i,0)<>L_date.text then


If file <> nil and file.Exists Then
//listbox7 col 0 was the date and col 2 was the filename of the file to delete.
if Listbox7.cell(i,0)<>L_date.text then
file.Delete
end if
End If
next
[/code]

any helps.?


thanks

Regards,
Rivo

Author:  Ballyanthony [ Wed Apr 24, 2013 7:54 am ]
Post subject:  Re: Deleting file based from a listbox data

If it was working before and it works again if you change the code back, then my conclusion would be Listbox7.cell(i,0) must equal tgl.text

I suggest you change the code to:

if Listbox7.cell(i,0)<>tgl.text then
file.Delete
else
MsgBox Listbox7.cell(i,0)+chr(13)+tgl.text
end if

And see what happens

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/