VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Directory Cleaner (recursively)

Gary Choma  (2 Submissions)   Files/File Controls/Input/Output   Visual Basic 3.0   Advanced   Wed 3rd February 2021

This function attempts to delete all files
and subdirectories of the given
directory name, and leaves the given
directory intact, but completely empty.
If the Kill command generates an error (i.e.
file is in use by another process -
permission denied error), then that file and
subdirectory will be skipped, and the
program will continue (On Error Resume Next).
EXAMPLE CALL:
ClearDirectory "C:\Temp\"

Inputs
Full path directory name

Assumes
Kill statement may error out for various reasons, which will prevent those files/directories from being deleted.

Returns
N/A

Side Effects
WARNING: If a subdirectory is prevented from being deleted (i.e. Kill statement errors out because of file access error), the loop will NOT terminate (While Len(sSubDir) > 0). This may not be an issue in most cases, but I just wanted to make clear the limitations of this code.

Rate Directory Cleaner (recursively) (3(3 Vote))
Directory Cleaner (recursively).bas

Directory Cleaner (recursively) Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters