In this article we will see how to make a simple folder locker app in VB.Net. With this folder locker app you will simply able to lock any folder and can able to unlock it later. So let's start.
HOW TO MAKE FOLDER LOCKER APPLICATION IN VB.NET
1) Open Visual Studio. Create new "Windows Form Application". Name it Folder locker or anything you want to name it and click on OK. Change the
2) Now add Label control and give it name.
3) Add 3 Button controls. Change text property of each button as Lock, Unlock and Exit. Change the (Name) property as ButonLock for Lock button, ButtonUnlock for Unlock button and ButtonExit for Exit button.
4) Now add two TextBox controls and place them near the Lock and Unlock button as shown in figure. Change the (Name) property of TextBox1 to txtBrowse and TextBox2 to txtUnBrowse.
5) Now add ProgressBar control and place it as shown in figure.
6) Add FolderBrowserDialog control.
7) Now go to the code section of form. Just Before the form1 class paste the following namespaces.
Imports System.IO Imports System.Drawing Imports System.Windows.Forms
8) Now add following code below the form1 class.
Public status As String Private arr As String() = New String(5) {} Private Sub Folder_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load status = "" arr(0) = ".{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}" arr(1) = ".{21EC2020-3AEA-1069-A2DD-08002B30309D}" arr(2) = ".{2559a1f4-21d7-11d4-bdaf-00c04f60b9f0}" arr(3) = ".{645FF040-5081-101B-9F08-00AA002F954E}" arr(4) = ".{2559a1f1-21d7-11d4-bdaf-00c04f60b9f0}" arr(5) = ".{7007ACC7-3202-11D1-AAD2-00805FC1270E}" End Sub
9) Now go to design view and double click on Lock button to launch event for lock button. Paste the following code within the lock button event.
status = arr(0) If FolderBrowserDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then Dim d As DirectoryInfo = New DirectoryInfo(FolderBrowserDialog1.SelectedPath) Dim selectedpath As String = d.Parent.FullName + d.Name ProgressBar1.Value = 40 If FolderBrowserDialog1.SelectedPath.LastIndexOf(".{") = -1 Then If (Not d.Root.Equals(d.Parent.FullName)) Then d.MoveTo(d.Parent.FullName & "\" & d.Name & status) Else d.MoveTo(d.Parent.FullName + d.Name & status) End If txtBrowse.Text = FolderBrowserDialog1.SelectedPath ProgressBar1.Value = 75 ProgressBar1.Value = 100 Else status = getstatus(status) d.MoveTo(FolderBrowserDialog1.SelectedPath.Substring(0, FolderBrowserDialog1.SelectedPath.LastIndexOf("."))) txtBrowse.Text = FolderBrowserDialog1.SelectedPath.Substring(0, FolderBrowserDialog1.SelectedPath.LastIndexOf(".")) End If End If
10) Now copy and paste the following code within Unlock button event.
status = arr(1) If FolderBrowserDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then Dim d As DirectoryInfo = New DirectoryInfo(FolderBrowserDialog1.SelectedPath) Dim selectedpath As String = d.Parent.FullName + d.Name ProgressBar1.Value = 40 ProgressBar1.Value = 100 If FolderBrowserDialog1.SelectedPath.LastIndexOf(".{") = -1 Then If (Not d.Root.Equals(d.Parent.FullName)) Then d.MoveTo(d.Parent.FullName & "\" & d.Name & status) Else d.MoveTo(d.Parent.FullName + d.Name & status) End If txtUnBrowse.Text = FolderBrowserDialog1.SelectedPath ProgressBar1.Value = 100 ProgressBar1.Value = 100 Else status = getstatus(status) d.MoveTo(FolderBrowserDialog1.SelectedPath.Substring(0, FolderBrowserDialog1.SelectedPath.LastIndexOf("."))) txtUnBrowse.Text = FolderBrowserDialog1.SelectedPath.Substring(0, FolderBrowserDialog1.SelectedPath.LastIndexOf(".")) End If End If
11) Now write getstatus function after the Unlock button code.
Private Function getstatus(ByVal stat As String) As String For i As Integer = 0 To 5 If stat.LastIndexOf(arr(i)) <> -1 Then stat = stat.Substring(stat.LastIndexOf(".")) End If Next i Return stat End Function End Class
12) Copy and paste code below within the Exit button event.
Me.Close()
13) Now compile the application by pressing Ctrl+F5 and test it whether it is works or not.
Click here to download Folder Locker Source Code.
Click here to download Folder Locker EXE file.
So that's it guys. Have a fun. Please don't forget to share this post and give us your valuable reply in the comment section below. Thank you!
Hey, I have a question, can you explain this to me: Public status As String
ReplyDeletePrivate arr As String() = New String(5) {}
Private Sub Folder_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
status = ""
arr(0) = ".{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}"
arr(1) = ".{21EC2020-3AEA-1069-A2DD-08002B30309D}"
arr(2) = ".{2559a1f4-21d7-11d4-bdaf-00c04f60b9f0}"
arr(3) = ".{645FF040-5081-101B-9F08-00AA002F954E}"
arr(4) = ".{2559a1f1-21d7-11d4-bdaf-00c04f60b9f0}"
arr(5) = ".{7007ACC7-3202-11D1-AAD2-00805FC1270E}"
End Sub
---> I don't get it, what's the number for ?
ReplyDeleteThanks for sharing, if you want more benefits then remain connect with us.
Folder Lock Final Crack