PowerShell file browser to demonstrate Windows Forms ListView control

This sample script has been created to demostrate the usage of Windows forms listview control in PowerShell

 
 
 
 
 
5 Star
(2)
Add to favorites
4/7/2010
E-mail Twitter del.icio.us Digg Facebook
  • Return a folder path
    3 Posts | Last post May 02, 2017
    • I added a button to choose a folder/file
      
      $button3_OnClick=
      {
          if($listView1.SelectedItems[0].tag -eq "Folder"){
              $path2 = $listView1.SelectedItems[0]
              $form1.Close()
          }
      }
      
      
      It returns ListViewItem: {test}
      
      How can i get it to return a full file path so i can use it in a foreach loop.  
    • Hi Manca, have you solved the problem ?
      
      I'd like to use the doubleclick function to open a file, is it possible ?
    • In response to Ramses147, 
      
      If you can find the $doubleClick event handler at line 70, which looks like this:
      
      $doubleClick= 
      {
      	if ($listView1.SelectedItems[0].tag -eq "File") {
      		[System.Windows.Forms.MessageBox]::Show("You double clicked a file")
      	} else {
      		Refresh-ListView $listView1.SelectedItems[0].Name
      	}
      }
      
      Just change that to this:
      
      $doubleClick= 
      {
      	if ($listView1.SelectedItems[0].tag -eq "File") {
      		[System.Windows.Forms.MessageBox]::Show("You double clicked a file")
              Invoke-Item $listView1.SelectedItems[0].Name
      	} else {
      		Refresh-ListView $listView1.SelectedItems[0].Name
      	}
      }
      
      That "Invoke Item" call will open the selected file for you :)