title: Go upper folder/directory VB.NET
body: <p>I'm making a file/folder explorer using a <code>ListView</code>, when clicking a folder, it shows its contents, but I can't make it go back to where I was before opening that folder, or better going on an upper folder. example I'm in <code>D:\Folder1\Subfolder1\Subfolder</code> and I want to go to its upper folder, I should be in <code>D:\Folder1\Subfolder1</code>, Everytime I click a button.</p>
  
  <p>And i have this code but what it does is it replaces all paths, making it looks like this <code>D:\Folder1</code> and I can't go back further. By the way the <code>Textbox</code> has a default value/text of <code>D:\Folder</code>.</p>
  
  <p>this is my code:</p>
  
  <pre><code>Dim lvs As String
  Private Sub ListView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.DoubleClick
      lvs = ListView1.SelectedItems(0).Text.ToString
      Form2.TextBox1.Text = Form2.TextBox1.Text &amp; "\" &amp; lvs
  End Sub
  
  Private Sub Button5_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
      Dim s As String = Form2.TextBox1.Text
      s.Replace("\" &amp; lvs, " ").TrimEnd()
  End Sub
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Hi, I updated my code, what I did was I'm putting the <code>ListView</code> items in an <code>Array</code> and I'm deleting the last element(the last folder path) and it works fine. but when I run my code, It only execute once and it cannot be repeated, what could be wrong?</p>
  
  <p>code:</p>
  
  <pre><code>Dim lvs As New List(Of String)
  Private Sub ListView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.DoubleClick
      If ListView1.SelectedItems.Count &gt; 0 Then
          For Each item As ListViewItem In ListView1.SelectedItems
              lvs.Add(item.Text)
          Next
      End If
          Form2.TextBox1.Text = Form2.TextBox1.Text &amp; "\" &amp; ListView1.SelectedItems(0).Text
  End Sub
  
   Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
      Label5.Text = Label5.Text.Replace("\" &amp; lvs.ElementAt(lvs.Count - 1), "")
  End Sub
  </code></pre>