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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

single action to delete multiple folders using an array 1

Status
Not open for further replies.

dbardwell

MIS
Aug 9, 2002
12
US
New to vb and trying to build an application that will delete multiple folders with a click and get the folder locations from an array.

The application is going to be used to remove old cached profiles from servers.

tia

"Resistance is futile. We are NDS you will be authenticated."
 
Code:
        For x As Integer = 0 To arr.Count - 1
            IO.Directory.Delete(arr.Item(x), True)
        Next

You must have try catch block

Zameer Abdulla
 
You will need to loop through the array, validate the path and delete the folder. Here is some code that might help to get you started, where Path is the path location in your array.
Code:
Dim l_strArr() as String
Dim PATH as string

'Load the array

'This loop could be performed several different ways.
For Each PATH in l_strArr
   If System.IO.Directory.exists(PATH) then _
      System.IO.Directory.delete(PATH, true)
   End If
Next

There may be some syntax errors but it gives you an idea on how to approach this.

If at first you don't succeed, then sky diving wasn't meant for you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top