hello rick van.
i already have that. but, my project was exe file already. but they call or locate the xml file, base on my resources. cause i change always the xml file. for use to open file, doc, exe, url or etc.
and but i have bug. thanks your respond. i really appreciate it.
but not like that i needed.
but if you have. other content about that.
Public Class Form1
Private mRootPath As String = "D:\Templates dotx"
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
Call LoadList()
TreeView1.ExpandAll()
End Sub
Sub LoadList()
Dim mRootNode As New TreeNode
mRootNode.Text = RootPath
mRootNode.Tag = RootPath
mRootNode.Nodes.Add("*DUMMY*")
TreeView1.Nodes.Add(mRootNode)
End Sub
Private Sub TreeView1_NodeMouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeNodeMouseClickEventArgs) Handles TreeView1.NodeMouseDoubleClick
If e.Node.ImageKey = "folder" Then Exit Sub
If e.Node.Tag = "" Then Exit Sub
Try
Process.Start(e.Node.Tag)
Catch ex As Exception
MessageBox.Show("Error opening file: " & ex.Message)
End Try
End Sub
Private Sub TreeView1_BeforeCollapse(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewCancelEventArgs) Handles TreeView1.BeforeCollapse
e.Node.Nodes.Clear()
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
e.Node.Nodes.Clear()
Dim mNodeDirectory As IO.DirectoryInfo
mNodeDirectory = New IO.DirectoryInfo(e.Node.Tag.ToString)
For Each mDirectory As IO.DirectoryInfo In mNodeDirectory.GetDirectories
Dim mDirectoryNode As New TreeNode
If mDirectory.Name = "Documents and Settings" Then
GoTo here
End If
mDirectoryNode.Tag = mDirectory.FullName
mDirectoryNode.Text = mDirectory.Name
mDirectoryNode.Nodes.Add("*DUMMY*")
e.Node.Nodes.Add(mDirectoryNode)
mDirectoryNode.ImageKey = CacheShellIcon(mDirectory.FullName)
mDirectoryNode.SelectedImageKey = mDirectoryNode.ImageKey
here:
Next
For Each mFile As IO.FileInfo In mNodeDirectory.GetFiles
If (Trim(TextBox1.Text)).Length > 0 Then
Dim mFileNode As New TreeNode
If InStr(UCase(mFile.Name), UCase(Trim(TextBox1.Text))) Then
mFileNode.Tag = mFile.FullName
mFileNode.Text = mFile.Name
mFileNode.ImageKey = CacheShellIcon(mFile.FullName)
mFileNode.SelectedImageKey = mFileNode.ImageKey & "-open"
e.Node.Nodes.Add(mFileNode)
End If
Else
Dim mFileNode As New TreeNode
mFileNode.Tag = mFile.FullName
mFileNode.Text = mFile.Name
mFileNode.ImageKey = CacheShellIcon(mFile.FullName)
mFileNode.SelectedImageKey = mFileNode.ImageKey & "-open"
e.Node.Nodes.Add(mFileNode)
End If
Next
End Sub
Public Declare Auto Function SHGetFileInfo Lib "shell32.dll" (ByVal pszPath As String, ByVal dwFileAttributes As Integer, ByRef psfi As SHFILEINFO, ByVal cbFileInfo As Integer, ByVal uFlags As Integer) As IntPtr
Public Const SHGFI_ICON As Integer = &H100
Public Const SHGFI_SMALLICON As Integer = &H1
Public Const SHGFI_LARGEICON As Integer = &H0
Public Const SHGFI_OPENICON As Integer = &H2
Structure SHFILEINFO
Public hIcon As IntPtr
Public iIcon As Integer
Public dwAttributes As Integer
<runtime.interopservices.marshalas(runtime.interopservices.unmanagedtype.byvaltstr,> _
Public szDisplayName As String
<runtime.interopservices.marshalas(runtime.interopservices.unmanagedtype.byvaltstr,> _
Public szTypeName As String
End Structure
Function GetShellIconAsImage(ByVal argPath As String) As Image
Dim mShellFileInfo As New SHFILEINFO
mShellFileInfo.szDisplayName = New String(Chr(0), 260)
mShellFileInfo.szTypeName = New String(Chr(0), 80)
SHGetFileInfo(argPath, 0, mShellFileInfo, System.Runtime.InteropServices.Marshal.SizeOf(mShellFileInfo), SHGFI_ICON Or SHGFI_SMALLICON)
Dim mIcon As System.Drawing.Icon
Dim mImage As System.Drawing.Image
Try
mIcon = System.Drawing.Icon.FromHandle(mShellFileInfo.hIcon)
mImage = mIcon.ToBitmap
Catch ex As Exception
mImage = New System.Drawing.Bitmap(16, 16)
End Try
Return mImage
End Function
Function CacheShellIcon(ByVal argPath As String) As String
Dim mKey As String = Nothing
If IO.Directory.Exists(argPath) = True Then
mKey = "folder"
ElseIf IO.File.Exists(argPath) = True Then
mKey = IO.Path.GetExtension(argPath)
End If
If ImageList1.Images.ContainsKey(mKey) = False Then
ImageList1.Images.Add(mKey, GetShellIconAsImage(argPath))
End If
Return mKey
End Function
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = Keys.Enter Then
If Trim(TextBox1.Text).Length > 0 Then
TreeView1.Nodes.Clear()
Call LoadList()
Call GetAllNodes()
TreeView1.Sort()
TreeView1.ExpandAll()
Else
TreeView1.Nodes.Clear()
Call LoadList()
TreeView1.Sort()
TreeView1.ExpandAll()
End If
End If
End Sub
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Protected Function GetAllNodes() As List(Of TreeNode)
Dim allNodes As List(Of TreeNode) = New List(Of TreeNode)()
For i As Integer = 0 To TreeView1.Nodes.Count - 1
GetAllNodes(TreeView1.Nodes(i), allNodes)
Next
Return allNodes
End Function
Protected Sub GetAllNodes(ByVal subRoot As TreeNode, ByVal allNodes As List(Of TreeNode))
If (subRoot Is Nothing) Then
Exit Sub
End If
allNodes.Add(subRoot)
For i As Integer = 0 To subRoot.Nodes.Count - 1
GetAllNodes(subRoot.Nodes(i), allNodes)
For Each aa In subRoot.Nodes(i).Nodes
If InStr(UCase(aa.ToString), UCase(Trim(TextBox1.Text))) Then
End If
Next
Next
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
End Sub
End Class
----- this my code but they not call the xml. they call the driver d: some like this..