Testing delete of directory before actual delete

Posted on 2007-10-18
Last Modified: 2010-03-30
I need to delete an entire directory but I only want to start the deleting process if all the contents can be deleted. If they can't I don't want to delete anything. Is there a way to do this?
Question by:wallway
    LVL 86

    Expert Comment

    AFAIK no. If you're worried about the 'transaction' you could always take copies of successfully deleted files so they can be restored if the transaction fails.
    LVL 92

    Expert Comment

    Only way would be to copy the entire directory before attempting delete.
    LVL 92

    Accepted Solution

    you could check access privs to all files before deleting but thats not a guarantee that the delete would work but may be enuf for you.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    This video teaches viewers about errors in exception handling.
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

    761 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

    8 Experts available now in Live!

    Get 1:1 Help Now