Launch and Open File

  1. 2 weeks ago

    This code is given as working in several forum posts:

    Dim app As FolderItem = SpecialFolder.Applications.child("TextEdit.app")
    Dim document As FolderItem = SpecialFolder.Desktop.child("APrincessofMars.txt")

    app.Launch(document.NativePath)

    While this code does launch the app passed ("Microsoft Word.app" or "TextEdit.app", etc.) it never causes the app to load the file.

    I have confirmed the file is on the desktop, is valid, etc.

    I get the open app, but the app never opens/loads the file passed -- and no error generated.

    Clearly, I am doing something wrong.

    Looking forward to your wisdom!

    Beginning with Xojo 2019 R 2.1 am also seeing this, earlier versions open the file as expected.

    So: use Xojo 2019 R 1.1 or earlier or use this workaroaund:

    Dim app As FolderItem = SpecialFolder.Applications.child("TextEdit.app")
    Dim document As FolderItem = SpecialFolder.Desktop.child("APrincessofMars.txt")
    
    dim sh as new shell
    dim command as String = "open -a " + app.ShellPath + " " + document.ShellPath
    sh.Execute(command)
  2. Christian M

    Jun 25 Xojo Pro Answer Germany

    Beginning with Xojo 2019 R 2.1 am also seeing this, earlier versions open the file as expected.

    So: use Xojo 2019 R 1.1 or earlier or use this workaroaund:

    Dim app As FolderItem = SpecialFolder.Applications.child("TextEdit.app")
    Dim document As FolderItem = SpecialFolder.Desktop.child("APrincessofMars.txt")
    
    dim sh as new shell
    dim command as String = "open -a " + app.ShellPath + " " + document.ShellPath
    sh.Execute(command)
  3. Markus R

    Jun 25 Testers, Xojo Pro Europe / Germany / Lower Saxon...
    Edited 2 weeks ago

    maybe if the path contains spaces you need " around.
    parameter delimiter is typically a space at windows.

  4. XOJO ... any response as to the difference in behavior between builds?

    Everyone ... will the workaround be acceptable to the App Store reviewers?

  5. Christian M

    Jun 25 Xojo Pro Germany

    @Hank M ... will the workaround be acceptable to the App Store reviewers?

    Depends on where the files you want to launch are located. Normally, sandboxed apps are not allowed to open arbitrary files, so depeneding where the files are located, your sandboxed app would not be able to open them. (The preferred way to open files in sandboxed apps is to use the „OpenFileDialog“ or „FolderItem.ShowOpenFileDialog“). So probably you would need to add some additional entitlements to your sandboxed app to make it work and make it pass the review process.

or Sign Up to reply!