Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Unhide folders

0.00/5 (No votes)
24 Apr 2014 1  
unhide folders after virus attack

Introduction

Most of us attached by the virus which adds the hidden attribute to every folder on your system. However after cleaning your system, your folders are still hidden.

So, that tip eases the unhide process of yours folders


Using the code

The key of this tip is this line

 File.SetAttributes("Dir", IO.FileAttributes.Normal)

The main part

Dim i As Long

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        'To start scanning for new logical drives
        ' Scanning every 500ms
        Timer1.Interval = 500
        Timer1.Start()

        'Adding the logical drives in the combobox
        Dim dirs() As String = Directory.GetLogicalDrives()

        For Me.i = dirs.GetLowerBound(0) To dirs.GetUpperBound(0)
            ComboBox1.Items.Add(dirs(i))
        Next i

    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

        Try
            For Each Dir As String In Directory.GetDirectories(ComboBox1.Text)
                ' Not included as cant be accessed 
                If Dir = ComboBox1.Text & "System Volume Information" Then
                Else
                    File.SetAttributes(Dir, IO.FileAttributes.Normal)
                End If
            Next

        Catch 'to catch any ex

        End Try

    End Sub

But, you need to check periodically any change in your logical drives added/removed

    Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
        'Clearing the combobox only if new logical drive inserted or removed
        If ComboBox1.Items.Item(ComboBox1.Items.Count - 1).ToString <> System.IO.Directory.GetLogicalDrives.Last.ToString Then

            ComboBox1.Items.Clear()

            Dim dirs() As String = Directory.GetLogicalDrives()

            For Me.i = dirs.GetLowerBound(0) To dirs.GetUpperBound(0)
                ComboBox1.Items.Add(dirs(i))
            Next i

        Else

        End If

    End Sub


License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here