Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting folders 1

Status
Not open for further replies.

markbellki

Technical User
Jan 21, 2003
7
AU
I've got myself in a real knot - not thinking straight.

I would like to know how to delete folders and files within folders.

eg the directory structure looks similar to this:

c:\objects
c:\objects\12345678
c:\objects\12345678\i.pal
c:\objects\12345678\lamp.pal
c:\objects\12345678\idle
c:\objects\12345678\idle\idle.ani
c:\objects\12345678\ne
c:\objects\12345678\ne\ne.ani
c:\objects\12345678\nw
c:\objects\12345678\nw\nw.ani
c:\scenery
c:\scenery\other
c:\scenery\other\12345678.ucs

I know that you can't do recursive calls of the Dir function and am at a bit of a loss.
 
Take a look at the Microsoft Scripting Runtime
(scrrun.dll). Set a reference to it through your project properties. Refer to vb help for FileSystemObject

I think you'll find that taking and object oriented aproach to it will be helpful.
 

>I know that you can't do recursive calls of the Dir function and am at a bit of a loss.

Yes you can use recursion with dir, or dir with recursion

To delete files use the "Kill" statement to remove directories use "RmDir"

or you can check out the removefolder method of the file system object.

Good Luck

By the way have you read FAQ222-2244?
 
See also thread222-710209. It gives two methods for deleting folders.

One with FileSystemObject (which is the simplest) and the other with SHFileOperation API function (which is a little bit longer).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top