Opening a file by code line

Hello,
I’m trying to open a file by giving the code a path to follow. Thanks to your suggestions I’m able to reach any folder not inside a SpecialFolder by coding like this:

OpDg = New OpenDialog

result = “/Users/myHD/FLDR1/FLDR2/FLDR”

OpDg.InitialFolder = new FolderItem (result, FolderItem.PathModes.Native)

I have a DeskTopPopUpMenu letting me choose among three files; what I’d like to do, and failing, is having the code open the chosen file, say myFile.wvr, inside that path.but I do not know how to obtain this. It does not work adding /myFile.wvr at the end of the path.
Maybe I should use an altogether different approach op coding. Any help will be appreciated

Thank you

If I understand you correctly, I think you want to look into the Folderitem object and use it like this:

Dim f as Folderitem

Dim path as string

path="path to file including filename"

f=new Folderitem(path)

That will give you a Folderitem that points to the file specified by the path variable. You can then use it with BinaryStream, TextInputStream, etc.

It does not work adding /myFile.wvr at the end of the path.

if you have a folder item object which is just a path
you can use .Child("myFile.wvr")

If you want to do it using a filedialog to choose a file, what you had initially is correct. The user is then presented with your chosen folder, and then chooses the file. What you get back from the filedialog is a folderitem for that file the user selected.

Opening that file is then the next step, and how you do that depends on what you want to do, as @Eric_Williams suggested.

In a way, yes but I also wanted the app to open the file without my intervention (generally speaking, it’s not a good idea but the code is not for distribution).
After an extensive testing I think I managed to do it.

Thanks everybody for your help

Well then cut out the filedialog step and just do such as:

Var  f as FolderItem, ff as TextInputStream

f  = new fFolderItem ("/path/to/the/file.abc", FolderItem.PathModes.Native)
ff = new TextInputStream (f)
ff.Open ()