locked
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 ?

    Thanks

    Sunday, August 25, 2013 11:59 AM

Answers

  • 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)
            System.IO.File.Delete("D:\Hidden\Hidden.txt")
        End Sub
    End Class
    Try this code
    Sunday, August 25, 2013 7:44 PM