Imports System.IO
Dim curPath As String = "C:\" Private Function updateListbox() ListBox1.Items.Clear() Dim di As New DirectoryInfo(curPath) Dim diArr As DirectoryInfo() = di.GetDirectories() Dim dri As DirectoryInfo For Each dri In diArr ListBox1.Items.Add("Dir: " & dri.Name) Next dri For Each foundFile As String In My.Computer.FileSystem.GetFiles(curPath) ListBox1.Items.Add(foundFile.Split("\")(foundFile.Split("\").Count() - 1)) Next End Function
Private Function removeFront(ByVal s As String) Dim r As String = Nothing For i As Integer = 0 To s.Count() - 1 If (i > 4) Then r &= s.Chars(i) Next Return r End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load updateListbox() End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click If (Not ListBox1.SelectedItem = Nothing) Then If (ListBox1.SelectedItem.ToString().StartsWith("Dir: ")) Then Dim dir As String = removeFront(ListBox1.SelectedItem.ToString()) curPath = curPath & dir & "\" updateListbox() Else MsgBox(curPath & ListBox1.SelectedItem.ToString()) Diagnostics.Process.Start(curPath & ListBox1.SelectedItem.ToString()) End If End If End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Dim pathParts As String() = curPath.Split("\") Dim backPath As String = Nothing For Each part As String In pathParts If (Not part = pathParts(pathParts.Count() - 2)) Then backPath &= part & "\" Next If (backPath.EndsWith("\\")) Then backPath = backPath.Remove(backPath.Count() - 1) curPath = backPath updateListbox() End Sub
Imports System.IO Public Class Form1 Dim curPath As String = "C:\" Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load updateListbox() End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click If (Not ListBox1.SelectedItem = Nothing) Then If (ListBox1.SelectedItem.ToString().StartsWith("Dir: ")) Then Dim dir As String = removeFront(ListBox1.SelectedItem.ToString()) curPath = curPath & dir & "\" updateListbox() Else MsgBox(curPath & ListBox1.SelectedItem.ToString()) Diagnostics.Process.Start(curPath & ListBox1.SelectedItem.ToString()) End If End If End Sub Private Function removeFront(ByVal s As String) Dim r As String = Nothing For i As Integer = 0 To s.Count() - 1 If (i > 4) Then r &= s.Chars(i) Next Return r End Function Private Function updateListbox() ListBox1.Items.Clear() Dim di As New DirectoryInfo(curPath) Dim diArr As DirectoryInfo() = di.GetDirectories() Dim dri As DirectoryInfo For Each dri In diArr ListBox1.Items.Add("Dir: " & dri.Name) Next dri For Each foundFile As String In My.Computer.FileSystem.GetFiles(curPath) ListBox1.Items.Add(foundFile.Split("\")(foundFile.Split("\").Count() - 1)) Next End Function Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Dim pathParts As String() = curPath.Split("\") Dim backPath As String = Nothing For Each part As String In pathParts If (Not part = pathParts(pathParts.Count() - 2)) Then backPath &= part & "\" Next If (backPath.EndsWith("\\")) Then backPath = backPath.Remove(backPath.Count() - 1) curPath = backPath updateListbox() End Sub End Class
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.