Putting in Rcyc bin

Posted on 2005-05-14
Last Modified: 2010-04-05
I have a program that puts files in the recyc bin, but if the file is in use it displays a system error saying access denied.  It does this even when I put Try... Except around it.  How can I get this to just bypass the file without a message display from the system?  (I'm using D5)

  with FileOpStruc do
    Wnd := 0;
    wFunc := FO_DELETE;
    pFrom := Pchar(s + #0 + #0);
    fFlags := FOF_ALLOWUNDO;
Question by:jexd99
    LVL 33

    Accepted Solution

    hello  jexd99, , the  API function   SHFileOperation(  )  does not seem to throgh an exception, this is a System function not a Delphi fuction, (so you get a system error message, not an exception message), so I do not think that the try  and   except  block will do anything at all for this. . . You should try and add the flags -




    and see if that might help, but sometimes the system will show an "Error" message, even with those flags, depending on the error

    Author Comment

    Thanks, I did experiment with those flags already (I thought nonconfirmation would work, but it doesn't).  I could check to see if the file is in use first, but I would rather just check it at the time of deleting as there has to be a way to handle this.

    Author Comment

    Consider it good, it now works :)  I made so many changes that I'm not sure exactly which one caused it to work, but one of the changes was the combo of all 3 you listed above, so I think that might have been the main piece for this!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
    Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now