|
-
July 28th, 2009, 07:07 AM
#1
Lock Folder
I set the password to folder. I made the xml folder inside the folder dat i want to lock.When the user double click on that folder ,folder doesn't open up.
In my code folder is locked,cz i m renaming the folder name .Suppose mine folder name is sonia,i rename it to sonia.{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}.
IN win xp,extension is hidden for the folder .{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0},but in vista extension is showing,i want to hide dat extension..how to do dat.can somebody tell me?
FOR REFERENCE see
http://www.codeproject.com/KB/files/...rotection.aspx
FrmMain
Code:
Option Strict On
Option Explicit On
Option Compare Text
Imports System.IO
Imports System.Xml
Public Class FrmMain
Dim obj As New FolderBrowserDialog
Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowse.Click
Dim status As String
status = ".{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}"
obj.Description = "Select Folder that You Want to LOCK!"
obj.ShowNewFolderButton = False
If obj.ShowDialog = Windows.Forms.DialogResult.OK Then
txtFolder.Text = obj.SelectedPath
Dim d As DirectoryInfo = New DirectoryInfo(obj.SelectedPath)
If Trim(txtFolder.Text) <> "" Then
If (obj.SelectedPath.LastIndexOf(".{") = -1) Then
Call SetPassword(txtFolder.Text)
If bSetPassword Then
d.MoveTo(d.Parent.FullName + "\" + d.Name + status)
End If
Else
txtFolder.Text = obj.SelectedPath.Substring(0, obj.SelectedPath.LastIndexOf("."))
Call CheckPassword()
If bPasswordMatch Then
File.Delete(obj.SelectedPath + "\p.xml")
d.MoveTo(obj.SelectedPath.Substring(0, obj.SelectedPath.LastIndexOf(".")))
End If
End If
End If
End If
End Sub
Private Sub SetPassword(ByVal sPath As String)
Dim obj As New FrmSetPassword
obj.ShowDialog()
End Sub
Private Sub CheckPassword()
Dim ReadXMlFile As XmlTextReader
ReadXMlFile = New XmlTextReader(obj.SelectedPath + "\p.xml")
While ReadXMlFile.Read
If ReadXMlFile.NodeType = XmlNodeType.Text Then
Dim obj As New FrmCheckPassword(ReadXMlFile.Value)
obj.ShowDialog()
Exit While
End If
End While
ReadXMlFile.Close()
End Sub
End Class
FrmSetPassword
Code:
Option Strict On
Option Explicit On
Option Compare Text
Imports System.Xml
Public Class FrmSetPassword
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
If Trim(txtPassword.Text) <> "" And Trim(txtConfirmPass.Text) <> "" Then
If Trim(txtPassword.Text) = Trim(txtConfirmPass.Text) Then
Dim xmldoc As XmlDocument = New XmlDocument
Dim xmlelem As XmlElement
Dim xmlnode As XmlNode
Dim xmltext As XmlText
xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, "", "")
xmldoc.AppendChild(xmlnode)
xmlelem = xmldoc.CreateElement("", "ROOT", "")
xmltext = xmldoc.CreateTextNode(txtPassword.Text)
xmlelem.AppendChild(xmltext)
xmldoc.AppendChild(xmlelem)
xmldoc.Save(FrmMain.txtFolder.Text + "\\p.xml")
bSetPassword = True
Me.Close()
Else
bSetPassword = False
MsgBox("Passwords Do Not Match", MsgBoxStyle.Information, Application.ProductName & " v" & Application.ProductVersion)
txtPassword.Clear()
txtConfirmPass.Clear()
txtPassword.Focus()
End If
Else
bSetPassword = False
MsgBox("Please Enter the Passwords", MsgBoxStyle.Information, Application.ProductName & " v" & Application.ProductVersion)
End If
End Sub
End Class
FrmCheckPassword
Code:
Option Strict On
Option Explicit On
Option Compare Text
Public Class FrmCheckPassword
Public sPubPassword_FILE As String
Public Sub New(ByVal sPassword_FILE As String)
InitializeComponent()
sPubPassword_FILE = sPassword_FILE
End Sub
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
If Trim(txtPassword.Text) = Trim(sPubPassword_FILE) Then
bPasswordMatch = True
Else
bPasswordMatch = False
MsgBox("Password Do Not Match", MsgBoxStyle.Information, Application.ProductName & " v" & Application.ProductVersion)
End If
Me.Close()
End Sub
End Class
Last edited by sonia.sardana; July 28th, 2009 at 07:49 AM.
-
July 28th, 2009, 05:49 PM
#2
Re: Lock Folder
What version of Vista? Even with hidden files (in XP, too) you can see files using the ATTRIB command. Your password is cleartext, and that is a bigger issue. Use the security of the OS.
-
July 28th, 2009, 09:59 PM
#3
Re: Lock Folder
What u mean by security of OS...I simply set the password textbox property Password Char to true..Is it not sufficient!!!!!
-
July 29th, 2009, 12:30 AM
#4
Re: Lock Folder
Not if you want to protect the data.
What version of Windows are you using???
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|