Advertisement
NiCz

How to Make A Folder Locker in Visual Basic 2008/2010

Aug 22nd, 2012
784
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.82 KB | None | 0 0
  1. How to Make A "Folder Locker" in Visual Basic 2008/2010
  2. Requirements:
  3. 2 Buttons (Button 1 - Lock) (Button 2 - Unlock)
  4. 1 TextBox
  5. 1 Progressbar
  6. 1 OpenBrowseDialog
  7. --
  8. First Code [Copy and Paste this Above Public Class Form1.]
  9. ~
  10. Imports System.IO
  11. Imports System.Drawing
  12. Imports System.Windows.Forms
  13. --
  14. Second Code [Copy and Paste this Below Public Class Form1.]
  15. ~
  16. status = ""
  17.         arr(0) = ".{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}"
  18.         arr(1) = ".{21EC2020-3AEA-1069-A2DD-08002B30309D}"
  19.         arr(2) = ".{2559a1f4-21d7-11d4-bdaf-00c04f60b9f0}"
  20.         arr(3) = ".{645FF040-5081-101B-9F08-00AA002F954E}"
  21.         arr(4) = ".{2559a1f1-21d7-11d4-bdaf-00c04f60b9f0}"
  22.         arr(5) = ".{7007ACC7-3202-11D1-AAD2-00805FC1270E}"
  23. --
  24. Third Code [Button 1 - Lock]
  25. ~
  26. status = arr(0)
  27.  
  28.  
  29.  
  30.         If FolderBrowserDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
  31.  
  32.  
  33.  
  34.             Dim d As DirectoryInfo = New DirectoryInfo(FolderBrowserDialog1.SelectedPath)
  35.  
  36.             Dim selectedpath As String = d.Parent.FullName + d.Name
  37.  
  38.             ProgressBar1.Value = 35
  39.  
  40.             If FolderBrowserDialog1.SelectedPath.LastIndexOf(".{") = -1 Then
  41.  
  42.  
  43.  
  44.                 If (Not d.Root.Equals(d.Parent.FullName)) Then
  45.  
  46.                     d.MoveTo(d.Parent.FullName & "\" & d.Name & status)
  47.  
  48.                 Else
  49.  
  50.                     d.MoveTo(d.Parent.FullName + d.Name & status)
  51.  
  52.                 End If
  53.  
  54.                 TextBox1.Text = FolderBrowserDialog1.SelectedPath
  55.                 ProgressBar1.Value = 70
  56.  
  57.                 ' PictureBox1.Image = Image.FromFile(Application.StartupPath & "\lock.jpg")
  58.                 ProgressBar1.Value = 100
  59.             Else
  60.  
  61.                 status = getstatus(status)
  62.  
  63.  
  64.  
  65.                 d.MoveTo(FolderBrowserDialog1.SelectedPath.Substring(0, FolderBrowserDialog1.SelectedPath.LastIndexOf(".")))
  66.  
  67.                 TextBox1.Text = FolderBrowserDialog1.SelectedPath.Substring(0, FolderBrowserDialog1.SelectedPath.LastIndexOf("."))
  68.  
  69.                 ' PictureBox1.Image = Image.FromFile(Application.StartupPath & "\unlock.jpg")
  70.  
  71.  
  72.  
  73.             End If
  74.  
  75.         End If
  76. --
  77. Fourth Code [Button 2 - Unlock]
  78. ~
  79. status = arr(1)
  80.  
  81.  
  82.  
  83.         If FolderBrowserDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
  84.  
  85.  
  86.  
  87.             Dim d As DirectoryInfo = New DirectoryInfo(FolderBrowserDialog1.SelectedPath)
  88.  
  89.             Dim selectedpath As String = d.Parent.FullName + d.Name
  90.  
  91.  
  92.  
  93.             If FolderBrowserDialog1.SelectedPath.LastIndexOf(".{") = -1 Then
  94.  
  95.  
  96.  
  97.                 If (Not d.Root.Equals(d.Parent.FullName)) Then
  98.  
  99.                     d.MoveTo(d.Parent.FullName & "\" & d.Name & status)
  100.  
  101.                 Else
  102.  
  103.                     d.MoveTo(d.Parent.FullName + d.Name & status)
  104.  
  105.                 End If
  106.  
  107.                 TextBox1.Text = FolderBrowserDialog1.SelectedPath
  108.  
  109.                 'PictureBox1.Image = Image.FromFile(Application.StartupPath & "\lock.jpg")
  110.  
  111.             Else
  112.  
  113.                 status = getstatus(status)
  114.  
  115.  
  116.  
  117.                 d.MoveTo(FolderBrowserDialog1.SelectedPath.Substring(0, FolderBrowserDialog1.SelectedPath.LastIndexOf(".")))
  118.  
  119.                 TextBox1.Text = FolderBrowserDialog1.SelectedPath.Substring(0, FolderBrowserDialog1.SelectedPath.LastIndexOf("."))
  120.  
  121.                 ' PictureBox1.Image = Image.FromFile(Application.StartupPath & "\unlock.jpg")
  122.  
  123.  
  124.  
  125.             End If
  126.  
  127.         End If
  128. --
  129. Last Code [Between "End Sub" and "End Class"]
  130. ~
  131. Private Function getstatus(ByVal stat As String) As String
  132.  
  133.         For i As Integer = 0 To 5
  134.  
  135.             If stat.LastIndexOf(arr(i)) <> -1 Then
  136.  
  137.                 stat = stat.Substring(stat.LastIndexOf("."))
  138.  
  139.             End If
  140.  
  141.         Next i
  142.  
  143.         Return stat
  144.  
  145.  
  146. CODES ARE 100% FROM NiCz
  147.     End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement