Author: matthisco | Posted on: 4/7/2010 7:27:21 AM | Views : 306

Hi,
MY script below loops through files in a directory and deletes them.
Is there anyway I can use try/catch and generate an error message if a file doesnt delete?
Also, can I display the number of files deleted if the script weas successful?
My code is below:
Protected Sub deletedocs(ByVal sender As Object, ByVal e As EventArgs)
 
        Dim ctr As Integer = 0
        Dim di As New DirectoryInfo("xx/xx/xx/")
        Dim fis As FileInfo() = di.GetFiles

        For Each fi As FileInfo In fis
          
                fi.Delete()

                ctr ...

Go to the complete details ...