A Program That Locks Your Files
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
10 posts
Page 1 of 1
Okay, in this post I will show you something Useful.
It Locks your Files and It Adds a Padlock Icon to know its locked.
Note: I THINK SOMEONE ALREADY POSTED THIS.
Requirements:
* 2 Buttons
* 1 TextBox
* 1 ProgressBar
* 1 FolderBrowserDialog
Name:
* Button1 - Lock
* Button2 - Unlock
Let's start.
First, Create a New Project "Application Form"
Second, Customize it as you like.
Third, After you finished customizing your form.
-- Let's start Coding --
Right click on the form and Press "View Code"
On the Code Tab. Copy and Paste this Above Public Class Form1.
Try and Debug it. It should work.
Note: IF YOUR STILL NOT SURE THAT IT'S NOT SAFE. MAKE A FOLDER AND ADD .TXT AND TRY LOCKING AND UNLOCKING IT.
Peace!
It Locks your Files and It Adds a Padlock Icon to know its locked.
Note: I THINK SOMEONE ALREADY POSTED THIS.
Requirements:
* 2 Buttons
* 1 TextBox
* 1 ProgressBar
* 1 FolderBrowserDialog
Name:
* Button1 - Lock
* Button2 - Unlock
Let's start.
First, Create a New Project "Application Form"
Second, Customize it as you like.
Third, After you finished customizing your form.
-- Let's start Coding --
Right click on the form and Press "View Code"
On the Code Tab. Copy and Paste this Above Public Class Form1.
Code: Select all
After adding the Codes Given Above. Copy and Paste this Below Public Class Form1.
Imports System.IO
Imports System.Drawing
Imports System.Windows.Forms
Code: Select all
Now, Go back to Form1 Design and Double Click The Form. Clicking the Form will give you Form1_Load. Add this Code.
Public status As String
Private arr As String() = New String(5) {}
Code: Select all
Go back again to Form1 Design and Double Click the Lock Button (Button1). And Add this Codes.
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}"
Code: Select all
Go back again to Form1 Design and Double Click the Unlock Button (Button2). And add this Codes.
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
Code: Select all
Now, the last code. Add this Between End Sub and End Class.
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
Code: Select all
Okay, It's done!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
Try and Debug it. It should work.
Note: IF YOUR STILL NOT SURE THAT IT'S NOT SAFE. MAKE A FOLDER AND ADD .TXT AND TRY LOCKING AND UNLOCKING IT.
Peace!
You do not have the required permissions to view the files attached to this post.
How can I achieve the same look that you used on the form? Very nice compliment
clapper;

I'm in the empire business.
KraZy wrote:How can I achieve the same look that you used on the form? Very nice complimentviewtopic.php?f=38&t=2000clapper;
Dam did something with the program and now lost all folders and almost everything hope i can get it back.
omg;
omg;
Try and search the Folders in Run.exe or something
I really like this program but I am in need of your help. The thing is I somehow need to specify the folder using a variable without actually using the file browser. I mean I will have a predefined folder which should get locked/unlocked. I don't want to allow the user to actually chose the file/folder. Like for example I will have a string variable "path" and it will have the value "C:/Windows/file" and I want the program to work solely on this file no other thanks
evil mmm wrote:I really like this program but I am in need of your help. The thing is I somehow need to specify the folder using a variable without actually using the file browser. I mean I will have a predefined folder which should get locked/unlocked. I don't want to allow the user to actually chose the file/folder. Like for example I will have a string variable "path" and it will have the value "C:/Windows/file" and I want the program to work solely on this file no other thanksIn my time that would take some work because I'm very busy. What are you saying is "Make a folder somewhere and add the codes to automatically lock/unlock that folder by clicking the buttons?"
3aaBrSbeel wrote:Exactly! Thank you for replying waiting for the code wahooo;evil mmm wrote:I really like this program but I am in need of your help. The thing is I somehow need to specify the folder using a variable without actually using the file browser. I mean I will have a predefined folder which should get locked/unlocked. I don't want to allow the user to actually chose the file/folder. Like for example I will have a string variable "path" and it will have the value "C:/Windows/file" and I want the program to work solely on this file no other thanksIn my time that would take some work because I'm very busy. What are you saying is "Make a folder somewhere and add the codes to automatically lock/unlock that folder by clicking the buttons?"
Ok, I'll PM you when I have it. :P
3aaBrSbeel wrote:Ok, I'll PM you when I have it. :PI found it out myself thanks for trying to help

10 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023