FolderItem confusion

I have following code:

lfile =  GetFolderItem("MemberTree:MemberTree.mpkg:", 0)
lfile.Launch    'launch the actual pkg file

This worked in previous version of Xojo

MemberTree is name of Disk image
and MemberTree.mpkg is name of installer that needs to be launched.

It no longer is working. What do I need to do?

That path is an old style absolute path - and is no longer valid and I doubt Xojo would give you a valid folder item from it
You’ll need to change it to a newer style - not sure I would use an absolute path but …
Probably something like /Volumes/MemberTree/MemberTree.mpkg

BUT I still would not do this
I might do something more like this (written all in the forum text editor so there may be bugs in this)

   dim f as Folderitem = GetFolderItem("/Volumes"/ Fodleritem.PathTypeAbsolute)
   if f is Nil then
       // problems - cant find it so bail out !
      return// false true or something to indicate that starting the installer failed
  end if

  f = f.Child("MemberTree")
   if f is Nil then
       // problems - cant find it so bail out !
      return// false true or something to indicate that starting the installer failed
  end if

 dim filetoLaunch as Folderitem = f.child("MemberTree.mpkg")
   if filetoLaunch is Nil then
       // problems - cant find it so bail out !
      return// false true or something to indicate that starting the installer failed
  end if

  fileToLaunch.Launch

That didn’t launch the pkg.

Anybody have any ideas?

Think I got it stand by

It’s working, Thanks Norman

The interesting part on this is the .child("… thing.

Why ?

[quote=479264:@Richard Albrecht]I have following code:

lfile =  GetFolderItem("MemberTree:MemberTree.mpkg:", 0)

This worked in previous version of Xojo[/quote]

As already mentioned by others - 2019r2+ won’t work properly any longer with old style Absolute Paths.
Another approach for your situation would be: Loop through the currently mounted Volumes using DriveAt, and see if there is a .Child("MemberTree.mpkg") in there.

The bigger problem is those situations where you still have stored references as “Absolute Path”.
If you only have that and need to get the FolderItem with current Xojo Versions:

Var f1 As FolderItem = GetFolderItem("MemberTree:MemberTree.mpkg:", FolderItem.PathTypeAbsolute) Var f2 As New FolderItem("MemberTree:MemberTree.mpkg:", FolderItem.PathTypeAbsolute) Var g As FolderItem = GetFolderItemFromAbsolutePath("MemberTree:MemberTree.mpkg:")
f1 and f2 seem not to give the (previously expected) result any more. One could blame Xojo for breaking existing code that still compiles. So you have to write your own method of getting the correct FolderItem back when you only have an Absolute Path - g should work as it used to work before in older Xojo versions. Add this Method to a public Module:

[code]Public Function GetFolderItemFromAbsolutePath(psAbsolutePath As String) as FolderItem
Dim sNativePath As String

#If TargetMacOS Then

Declare Function CFURLCopyFileSystemPath Lib "Foundation" (anURL As Ptr, pathStyle As Int32) As CFStringRef
Declare Function CFURLCreateWithFileSystemPath Lib "Foundation" (CFURLCreateWithFileSystemPath As Ptr, filePath As CFStringRef, pathStyle As Int32) As Ptr

Const kCFURLPOSIXPathStyle = 0
Const kCFURLHFSPathStyle = 1

Dim ptrNSURL As Ptr = CFURLCreateWithFileSystemPath(nil, psAbsolutePath, kCFURLHFSPathStyle)
sNativePath = CFURLCopyFileSystemPath(ptrNSURL, kCFURLPOSIXPathStyle)

#Else
'Windows, Linux: NativePath is the same as Xojo’s deprecated AbsolutePath
sNativePath = psAbsolutePath

#EndIf

Return New FolderItem(sNativePath, FolderItem.PathTypeNative)

End Function[/code]

Again: in your situation - better do it some other way without using AbsolutePath’s.
The above Method will be helpful to still access previously saved “Absolute Path references”. From there, you’d better migrate to some other path format.