Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Recycle bin function

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Ken Lundberg
    Guest replied
    Ahhhhhh, the plot thickens.

    It appears the failure was not from the checkbox, but from this slight code modification:

    RetVal = RecycleBin(command$) ' for command line guys like me

    In this case, the file is always "deleted", rather than recycled. Any ideas..?

    Leave a comment:


  • Egbert Zijlema
    replied
    Ken,
    Look in your recycle bin's properties. If "Do not move files to the Recycle Bin" is checked, files will be definitely deleted immediately.
    Egbert

    Leave a comment:


  • Ken Lundberg
    Guest replied
    Hello Egbert,

    Thank you for the code you post on this forum. I have a quick question for you. After successfully calling the RecycleBin function, is the recycled file supposed to appear in the Recyle Bin..?

    After "recycling" 2 files, my recycle bin is as empty as before I started.

    - ken

    Leave a comment:


  • Egbert Zijlema
    started a topic Recycle bin function

    Recycle bin function

    Don't KILL files-to-delete anymore, but send them to the Recycle Bin, in the way Windows Explorer itself does.
    This example code sends a file MYFILE.TXT from the root directory to the bin.

    Code:
    #COMPILE EXE
    #INCLUDE "WIN32API.INC"
       
    FUNCTION RecycleBin(FilNam AS STRING) AS LONG
      LOCAL shfo AS SHFILEOPSTRUCT                 ' predefined structure
      LOCAL szSource AS ASCIIZ * 64
    
      szSource = FilNam + CHR$(0)                  ' convert to ASCIIZ
      shfo.wFunc = %FO_DELETE                      ' function delete file
      shfo.pFrom = VARPTR(szSource)                ' pointer to file
      shfo.fFlags = %FOF_ALLOWUNDO                 ' enable undo
    
      dummy& = SHFileOperation(shfo)               ' call funtion
      FUNCTION = shfo.fAnyOperationsAborted        ' return value, either 0 or non-zero
    END FUNCTION
      
    FUNCTION PBMAIN()
      LOCAL RetVal AS LONG
      RetVal = RecycleBin("C:\MYFILE.TXT")
       
      ' use the following lines only when the deleted file is part of an array or in  a listbox
      IF RetVal = 0 THEN
        ARRAY DELETE StringArray(index)
        LISTBOX DELETE hDlg,  %IDLISTBOX,  position&
      END IF
    END FUNCTION
Working...
X