Click here to Skip to main content
15,868,141 members
Articles / Programming Languages / Visual Basic
Reference

Unhide folders

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
24 Apr 2014CPOL 29.4K   5   2
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

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

The main part

VB.NET
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

VB.NET
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Systems Engineer Gizasystems
Egypt Egypt
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralAlternate Pin
DaveAuld30-Apr-14 5:22
professionalDaveAuld30-Apr-14 5:22 
QuestionAttrib Pin
DaveAuld24-Apr-14 22:52
professionalDaveAuld24-Apr-14 22:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.