on 2/29/08 9:41 AM, Lennox Jacob at lenpartico at yahoo dot com wrote:
> Hello,
>
> I have the following code in a pushbutton. When the pushbutton is pushed (the
> name of the folder is in EditField1), the files to be deleted comes up in the
> message box and the total number of files deleted also comes up, but the files
> are not actually deleted.
>
> Dim TIS as TextInputStream
> Dim TOS as TextOutputStream
> dim f, File As FolderItem
> dim i,j As Integer
> dim S As string
> Dim DeletingFilesFolderName as string = EditField1.Text
> f=DocumentsFolder.child(DeletingFilesFolderName)
> j=0
> for i=1 to f.Count 'Every file in the folder
>
> File=f.trueItem(i)
> if File<>nil then
> If File.name.left(3) = "200" then
>
> TIS = File.OpenAsTextFile
> S = TIS.ReadAll // Open the file and start reading and input the
> lines as the come
>
> if Trim(S) = "" or Trim(S) = chr(13) then
> msgbox File.Name + " deleted"
> File.delete
> j=J+1
> end if
>
> end if
>
> end if
> next
> msgbox str(j) + " files deleted from folder " + DeletingFilesFolderName
>
> Why aren't these files deleted?
Because the files are still open. I would add TIS = nil after the ReadAll
call to force the TextInputStream to close.
Chris
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|