Delete hidden files RRS feed

  • Question

  • Suppose I have a file that is hidden and the location and filename is d:\filelocation\filename.exe

    I want that when i click on a button, my program should remove the file with full access permissions, how can i do this ?


    Sunday, August 25, 2013 11:59 AM


  • Imports System.IO
    Public Class Form1
        Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
            Dim attributes As FileAttributes
            attributes = File.GetAttributes("D:\Hidden\Hidden.txt")
            If attributes And FileAttributes.System = FileAttributes.Hidden Then
                attributes = attributes And (Not FileAttributes.Hidden)
            End If
            If attributes And FileAttributes.ReadOnly = FileAttributes.ReadOnly Then
                attributes = attributes And (Not FileAttributes.ReadOnly)
            End If
            File.SetAttributes("D:\Hidden\Hidden.txt", attributes)
        End Sub
    End Class
    Try this code
    Sunday, August 25, 2013 7:44 PM