Question Finding and deleting files of a certain extension

Duplex

New member
Joined
Jun 28, 2008
Messages
4
Programming Experience
Beginner
Hello.

I have been asked to develop a small application that deletes all files of a certain extension out a chosen folder (The folder path has been stored in a string called InstallationFolder) and it's sub-directories.

I have been asked that it had a windows GUI so it can't be a console app.

Using DLL's is not a problem.

Thanks,
Duplex
 
Use code like this:
VB.NET:
For Each filepath As String In IO.Directory.GetFiles(InstallationFolder, "*.txt", IO.SearchOption.AllDirectories)
    Try
        IO.File.Delete(filepath)
        ListBox1.Items.Add(filepath & " deleted")
    Catch ex As Exception
        ListBox1.Items.Add(filepath & " not deleted, " & ex.Message)
    End Try
Next
 
Back
Top