Launch a file when double-clicking on a listbox

Hello,
By double clicking on my Listbox1, I want to open the clicked file whose path is passed as a Listbox1.RowTagAt() parameter. I am not familiar with the “Folderitem.FromSaveInfo()” command that replaces the depreciated “FolderItem.GetRelative()” command.
I am inspired by an old source that displayed this:

Dim f As New FolderItem
launchFile = f.GetRelative(RowTag(ListIndex))
If launchFile <> Nil And launchFile.Exists Then
  launchFile.Open()
End If

I tried to translate (unsuccessfully) into :

If Listbox1.RowCount >= 0 Then
  Var path As String 
  Var launchFile As FolderItem
  
  Var f As New FolderItem
 
  //launchFile = f.FromSaveInfo(Me.RowTagAt(Me.SelectedRowIndex)) //for test
  path = Listbox1.RowTagAt(Listbox1.SelectedRowIndex)
  launchFile = f.FromSaveInfo(path)   //return an folderitem
  
  If launchFile <> Nil Then  //launchFile always "nil" !
    launchFile.Open 
  End If
End If

A little help will do me good. Thanks.

Can you save in “RowTagAt” the object “FolderItem” directly?
So you can directly use the Open Method.

If you can’t, you must use this code (if you use 2019r2+):

Var launchFile as FolderItem
launchFile = new FolderItem(path, FolderItem.PathModes.Native)   'for example

As Ant says above, if you Populate the listbox with

Listbox1.RowTagAt(some_row_number) = theFolderitem

Then to launch it, all you should NEED to do is:

theFolderitem = Listbox1.RowTagAt(Listbox1.SelectedRowIndex) 
  If launchFile <> Nil  and launchfile.exists Then 
    launchFile.Open 
  End If
1 Like

Thanks you. That’s run !