Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How to Make A "Folder Locker" in Visual Basic 2008/2010
- Requirements:
- 2 Buttons (Button 1 - Lock) (Button 2 - Unlock)
- 1 TextBox
- 1 Progressbar
- 1 OpenBrowseDialog
- --
- First Code [Copy and Paste this Above Public Class Form1.]
- ~
- Imports System.IO
- Imports System.Drawing
- Imports System.Windows.Forms
- --
- Second Code [Copy and Paste this Below Public Class Form1.]
- ~
- 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}"
- --
- Third Code [Button 1 - Lock]
- ~
- 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 = 35
- 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
- TextBox1.Text = FolderBrowserDialog1.SelectedPath
- ProgressBar1.Value = 70
- ' PictureBox1.Image = Image.FromFile(Application.StartupPath & "\lock.jpg")
- ProgressBar1.Value = 100
- Else
- status = getstatus(status)
- d.MoveTo(FolderBrowserDialog1.SelectedPath.Substring(0, FolderBrowserDialog1.SelectedPath.LastIndexOf(".")))
- TextBox1.Text = FolderBrowserDialog1.SelectedPath.Substring(0, FolderBrowserDialog1.SelectedPath.LastIndexOf("."))
- ' PictureBox1.Image = Image.FromFile(Application.StartupPath & "\unlock.jpg")
- End If
- End If
- --
- Fourth Code [Button 2 - Unlock]
- ~
- 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
- 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
- TextBox1.Text = FolderBrowserDialog1.SelectedPath
- 'PictureBox1.Image = Image.FromFile(Application.StartupPath & "\lock.jpg")
- Else
- status = getstatus(status)
- d.MoveTo(FolderBrowserDialog1.SelectedPath.Substring(0, FolderBrowserDialog1.SelectedPath.LastIndexOf(".")))
- TextBox1.Text = FolderBrowserDialog1.SelectedPath.Substring(0, FolderBrowserDialog1.SelectedPath.LastIndexOf("."))
- ' PictureBox1.Image = Image.FromFile(Application.StartupPath & "\unlock.jpg")
- End If
- End If
- --
- Last Code [Between "End Sub" and "End Class"]
- ~
- 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
- CODES ARE 100% FROM NiCz
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement