Announcement

Collapse
No announcement yet.

Delete file to the recycle bin

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

  • Delete file to the recycle bin

    after modifying it to cc 3.04, i tried egbert's code at:
    http://www.powerbasic.com/support/pb...ad.php?t=22533

    and it does indeed delete the file but it doesn't show up in
    the recycle bin.

    any updates to this, maybe?

    okay, to expand a little, egbert's example works perfectly but
    when i incorporate it into one of my programs, it deletes but
    doesn't move it to the recycle bin.
    ------------------

    never mind. come to find out, i needed to tack on the full path
    to the file name. works okay now.



    [this message has been edited by mel bishop (edited december 20, 2006).]
    There are no atheists in a fox hole or the morning of a math test.
    If my flag offends you, I'll help you pack.

  • #2
    Mel, here you go.
    Code:
    'test code send file to recycle bin
    #INCLUDE "win32api.inc"
    DECLARE FUNCTION RecycleBin(FilNam AS STRING) AS LONG
    FUNCTION PBMAIN() AS LONG
       LOCAL filNam AS STRING
       filNam="test.fil"
       IF MID$(filnam,2,1)<>":" THEN x$=CURDIR$+"\"+filnam:filnam=x$
    'make a dummy file to delete
       OPEN "test.fil" FOR OUTPUT AS #1
       PRINT
       PRINT #1,"TEST" 'szsource;
       CLOSE
    'send it to recycle bin
       lResult&=RecycleBin(filnam)
       WAITKEY$
    END FUNCTION
    
    FUNCTION RecycleBin(FilNam AS STRING) AS LONG
      LOCAL shfo AS SHFILEOPSTRUCT                 ' predefined structure
      LOCAL szSource AS ASCIIZ * %MAX_PATH '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
    ------------------
    See Lances notes about this.

    Client Writeup for the CPA


    mailto:[email protected][email protected]</A>

    [This message has been edited by Fred Buffington (edited December 20, 2006).]
    Client Writeup for the CPA

    buffs.proboards2.com

    Links Page

    Comment


    • #3
      To quiet mode use

      shfo.fFlags = %FOF_ALLOWUNDO OR %FOF_NOCONFIRMATION ' enable undo in quiet mode


      ------------------
      Arthur Gomide
      Como diria nosso profeta da bola, Dadá Maravilha: "Para toda Problemática existe uma Solucionática!"
      "The trouble with quotes on the Internet is that you can never know if they are genuine." - Abraham Lincoln.

      Comment


      • #4
        Originally posted by Arthur Gomide:
        ...quiet mode...
        ?

        Oh. Do you mean "Are you sure" doesn't pop up?
        ------------------


        [This message has been edited by Mel Bishop (edited December 20, 2006).]
        There are no atheists in a fox hole or the morning of a math test.
        If my flag offends you, I'll help you pack.

        Comment


        • #5
          Originally posted by Mel Bishop:
          "Are you sure"?
          Right! No query!


          ------------------
          Arthur Gomide
          Como diria nosso profeta da bola, Dadá Maravilha: "Para toda Problemática existe uma Solucionática!"
          "The trouble with quotes on the Internet is that you can never know if they are genuine." - Abraham Lincoln.

          Comment


          • #6
            You cannot recycle files on a network share or a mapped drive - an error message will be displayed. You must pass a fully qualified file name to RecycleBin function - an error will be displayed if the file name doesn't match.


            ------------------
            Arthur Gomide
            Como diria nosso profeta da bola, Dadá Maravilha: "Para toda Problemática existe uma Solucionática!"
            "The trouble with quotes on the Internet is that you can never know if they are genuine." - Abraham Lincoln.

            Comment

            Working...
            X