Hi, anyone could be help me?
I have a simple Windows application, it list all Directories from a specified path in a liestview. My Listview have 2 column. First one show only icons and second one is the name of the Directory. Now i have a context menu "open dir". It should be open the Directory in/with explorer - Doesnt work.
The Problem part, i think, is following event: ToolStripMenuItem1_Click
Here is my Code:
thx
I have a simple Windows application, it list all Directories from a specified path in a liestview. My Listview have 2 column. First one show only icons and second one is the name of the Directory. Now i have a context menu "open dir". It should be open the Directory in/with explorer - Doesnt work.
The Problem part, i think, is following event: ToolStripMenuItem1_Click
Here is my Code:
VB.NET:
Imports System
Imports System.IO
Public Class Form1
'Variablen
' Dim txtangabe As String = txtbox1.Text
Dim suchordner As New DirectoryInfo("D:\MusikVidz") 'Root Ordner angeben
Dim unterordner As DirectoryInfo() = suchordner.GetDirectories 'Sub Ordner einlesen in variable
Dim ordnerinfo As DirectoryInfo 'Einzelnen Ordner in Variable speichern
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Liste löschen
ListView1.Items.Clear()
'suchordner = New DirectoryInfo(InputBox("bitte Verzeichnis angeben"))
For Each Me.ordnerinfo In unterordner ' Für jedes Ordner welches in der Schleife durchläuft erstelle ein Eintrag in die Listview (2.spalte)
With ListView1.Items.Add("", 0) 'die 0 = die ID des bildes in der Imagelist
.SubItems.Add(ordnerinfo.Name) '2te Spalte
End With
Next (ordnerinfo)
End Sub
Private Sub ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem1.Click
Try
Dim lviTmp As System.Windows.Forms.ListViewItem
If ListView1.CheckedItems.Count > 1 Then
lviTmp = ListView1.CheckedItems.Item(1)
MsgBox(lviTmp.SubItems(1).Text)
Microsoft.VisualBasic.Shell(lviTmp.SubItems.Add(1).Text)
System.Diagnostics.Process.Start("explorer.exe", lviTmp.SubItems(1).Text)
End If
Catch ex As Exception
MsgBox(ex.ToString, MsgBoxStyle.Exclamation, "Fehler")
End Try
End Sub
End Class
thx