Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

VB.NET = Click button that deletes files

I want to make a program that deletes all the files in a desktop folder...
Well get a list of files in the desktop directory and delete each file. It's pretty self explanatory...
Look into system.io and use loops.
[Image: F2G97kn.png]
Use system.io and use a for loop to delete the amount of things in the selected folder
[Image: mU6Wh32.gif]
He's obviously looking for someone just to paste him the exact code to do it with no interest of learning.
System.io, learn it yourself otherwise you''re not progressing
I don't know if this is exactly what you want but:
PHP Code

<?php 
Sub DeleteFilesFromFolder
(Folder As String)
    If 
Directory.Exists(Folder) Then
        
For Each _file As String In Directory.GetFiles(Folder)
            
File.Delete(_file)
        
Next
        
For Each _folder As String In Directory.GetDirectories(Folder)

            
DeleteFilesFromFolder(_folder)
        
Next

    End 
If

End Sub

'Somewhere you call

DeleteFilesFromFolder("C:\New Folder") 

Source: https://stackoverflow.com/questions/2522...-folders-w
(May 27, 2017 03:52 PM)Scaliber Wrote:  I don't know if this is exactly what you want but:
PHP Code

<?php 
Sub DeleteFilesFromFolder
(Folder As String)
    If 
Directory.Exists(Folder) Then
        
For Each _file As String In Directory.GetFiles(Folder)
            
File.Delete(_file)
        
Next
        
For Each _folder As String In Directory.GetDirectories(Folder)

            
DeleteFilesFromFolder(_folder)
        
Next

    End 
If

End Sub

'Somewhere you call

DeleteFilesFromFolder("C:\New Folder") 

Source: https://stackoverflow.com/questions/2522...-folders-w

You can just delete folders instead of deleting all files from folders.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by essie98927Apr 25, 2022 02:40 AM 4 175 Apr 25, 2022 02:40 AM
Last Post: essie98927
[Python] by The Pulp FictionApr 24, 2022 12:22 AM 2 199 Apr 24, 2022 12:22 AM
Last Post: The Pulp Fiction
[.NET] by triplextremeSep 15, 2020 02:29 PM 7 223 Sep 15, 2020 02:29 PM
Last Post: Dredd