Hi all,

I hope someone can help me with this cause I don't have any idea what
is happening... :)

When I run following code I get the following exception "Access to the
path 'file.txt' is denied."

While I am trying to get all directories in 'dir' and not files (or
don't I?).

        Try
            For Each foundDir As String In
My.Computer.FileSystem.GetDirectories(dir)

                Dim DirProps As DirectoryInfo = New DirectoryInfo(dir)

                If DirProps.Name.Contains("temp") Then
                    My.Computer.FileSystem.DeleteDirectory(foundDir,
FileIO.DeleteDirectoryOption.DeleteAllContents)
                End If
            Next
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

What I am trying to do is check if 'temp' is in directory name and
delete the directory if it is.

Can someone help me with this one.

Tnx

Reply via email to