Visual Basic > Files Directories Drives
Delete all files in given directory
Delete all files in given directory 'Deleting files in directory 'make a new project; a drive/dir & file control 'insert the next code (use Insert/File) 'press F5 '---------------- code --------------------- Private sub DeleteFilesinDirectory() dim t% If File1.ListCount - 1 = 0 Then exit Sub list1.Clear For t% = 0 To File1.ListCount - 1 File1.ListIndex = t% File1.Selected(t%) = True list1.AddItem File1 Next t% dim antwoord antwoord = MsgBox("Are you sure about this?", 36) If antwoord <> 6 Then exit Sub For t% = list1.ListCount - 1 To 0 step -1 list1.ListIndex = t% list1.Selected(t%) = True Kill Dir1 & "\" & list1 Next t% End Sub Private sub Dir1_Change() File1 = Dir1.Path Call DeleteFilesinDirectory End Sub Private sub Drive1_Change() Dir1 = Drive1 End Sub Return
Visual Basic Codes
ActiveX
Miscellaneous
Applications
Code Snippets
Common Dialogs
Special Effects
Database Stuff
Date Time
Files Drives
Forms
Graphics Games
Internet Stuff
Multimedia
Other
Strings
Windows