我想創建一個程序,我可以保存自己的文件並能夠在打開程序時輸入密碼。一旦我輸入密碼,我就可以訪問,更改並打開我選擇放入的文件。有關我如何做到這一點的任何想法或鏈接?任何幫助是極大的讚賞。我確實嘗試過,但是我得到了UnauthorizedAccessException。我明白了,當它到達: 對於每個mDirectory作爲IO.DirectoryInfo在mNodeDirectory.GetDirectories在TreeView1_BeforeExpand如何創建我自己的Windows資源管理器
Private mRootPath As String = "C:\Users"
Property RootPath As String
Get
Return mRootPath
End Get
Set(ByVal value As String)
mRootPath = value
End Set
End Property
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim mRootNode As New TreeNode
mRootNode.Text = RootPath
mRootNode.Tag = RootPath
mRootNode.Nodes.Add("*DUMMY*")
TreeView1.Nodes.Add(mRootNode)
End Sub
Private Sub TreeView1_BeforeCollapse(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewCancelEventArgs) Handles TreeView1.BeforeCollapse
' clear the node that is being collapsed
e.Node.Nodes.Clear()
' add a dummy TreeNode to the node being collapsed so it is expandable
e.Node.Nodes.Add("*DUMMY*")
End Sub
Private Sub TreeView1_BeforeExpand(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewCancelEventArgs) Handles TreeView1.BeforeExpand
' clear the expanding node so we can re-populate it, or else we end up with duplicate nodes
e.Node.Nodes.Clear()
' get the directory representing this node
Dim mNodeDirectory As IO.DirectoryInfo
mNodeDirectory = New System.IO.DirectoryInfo(e.Node.Tag.ToString)
' add each subdirectory from the file system to the expanding node as a child node
For Each mDirectory As IO.DirectoryInfo In mNodeDirectory.GetDirectories
' declare a child TreeNode for the next subdirectory
Dim mDirectoryNode As New TreeNode
' store the full path to this directory in the child TreeNode's Tag property
mDirectoryNode.Tag = mDirectory.FullName
' set the child TreeNodes's display text
mDirectoryNode.Text = mDirectory.Name
' add a dummy TreeNode to this child TreeNode to make it expandable
mDirectoryNode.Nodes.Add("*DUMMY*")
' add this child TreeNode to the expanding TreeNode
e.Node.Nodes.Add(mDirectoryNode)
Next
End Sub
末級
順便說一句,我沒有寫在上面的代碼,我想它關閉鏈接我發現
*我得到UnauthorizedAccessException * ...在什麼時候? – IAbstract 2012-01-12 01:54:53
你應該真正專注於你遇到的單個問題,並以這種方式處理問題:你的標題並不反映你所問的問題。有一點背景範圍提出您遇到的具體問題以及發生問題的可疑代碼。您應該始終給出您從網上覆制的代碼的鏈接,以便作者獲得適當的信用。 – IAbstract 2012-01-12 02:01:52
這將有助於瞭解您正在使用的Windows版本。 XP沒有適用於Windows 7的管理默認設置。 – IAbstract 2012-01-12 02:06:20