How to show a file on disk ?

thought it should be simple, but it seems not.
I have a folderitem, and I want to show the file on the disk (not open it, only show it)
should ideally work on mac,linux or win

any hint ?
thanks.

Afficher le fichier: non. Afficher le dossier contenant le fichier oui.

Dsol / sorry.

just found this … https://forum.xojo.com/16010-reveal-file-in-explorer

ps: had to use google to find it, it did not show up with xojo forum search …

Was you able to implement one of the given advices ?

Or use NSWorkspaceMBS.selectFile(file as folderitem) as boolean in MBS Plugin for Mac:

[code]dim f as FolderItem

f=SpecialFolder.Desktop.Child(“test.txt”)

if NSWorkspaceMBS.selectFile(f) then
MsgBox “Ok”
else
MsgBox “failed”
end if[/code]

for Windows, you can use WindowsShellExecuteMBS:

[code]dim e as Integer
dim f as FolderItem

// show documents folder

f = SpecialFolder.Documents
e = WindowsShellExecuteMBS(0, “explore”, f.AbsolutePath, “”, “”, 10)[/code]

yes norman post is working for me (I only tested on macos but it seems consistent with other posts and threads )
for macos it uses applescript. hope Apple will not abandon it too soon !
anyway we have some shell equivalent if .

[code]Public Sub ShowFileOnDisk(f as folderitem)
If f is nil or not f.Exists then
Return
end if
#if TargetMacOS
dim a as AppleEvent = NewAppleEvent(“misc”, “slct”, “MACS”)
a.FolderItemParam("----") = f
If a.send then
a = NewAppleEvent(“misc”, “actv”, “MACS”)
If a.send then
//success
Else
//activate failed
End if
Else //select failed
End if
#ElseIf TargetWindows
dim s as new shell
s.execute("explorer.exe /select, "+chr(34)+f.shellpath+chr(34))
#elseif TargetLinux
// Use xdg-open which is desktop-independent, and should be available in most newer distros
// Otherwise fallback on the two major desktop dependent command tools
Dim sh As New Shell
Dim commandTools() As String = Array( “xdg-open”, “gnome-open”, “kde-open” )

For Each tool As String In commandTools
  sh.Execute( "which " + tool )
  If Left( sh.Result, 1 ) = "/" Then
    sh.Execute( tool + " " + f.Parent.ShellPath )
    Exit
  End If
Next

#endif
End Sub
[/code]

[quote=395901:@Christian Schmitz]Or use NSWorkspaceMBS.selectFile(file as folderitem) as boolean in MBS Plugin for Mac:

[code]dim f as FolderItem

f=SpecialFolder.Desktop.Child(“test.txt”)

if NSWorkspaceMBS.selectFile(f) then
MsgBox “Ok”
else
MsgBox “failed”
end if[/code]

for Windows, you can use WindowsShellExecuteMBS:

[code]dim e as Integer
dim f as FolderItem

// show documents folder

f = SpecialFolder.Documents
e = WindowsShellExecuteMBS(0, “explore”, f.AbsolutePath, “”, “”, 10)[/code][/quote]

sorry Christian, I’m really a fan of “don’t do it with a plugin when you can do it without” !

Works fine here on El Capitan. Thanks.

I get this Function here, I will search in which post after :
Public Sub RevealEltFinder(CetElt as FolderItem)

[code] #If TargetMacOS Then
Declare Function objc_getClass Lib “libobjc.dylib” ( name as CString ) as ptr
Declare Function sharedWorkspace Lib “AppKit” selector “sharedWorkspace” ( obj As ptr ) as ptr
Declare Function selectFile Lib “AppKit” selector “selectFile:inFileViewerRootedAtPath:” ( obj as ptr, fPath as CFStringRef, rootFullPath as CFStringRef ) as Boolean
Dim workspace as ptr = sharedWorkspace( objc_getClass( “NSWorkspace” ) )
’ assert ( workspace <> nil, CurrentMethodName + " is Nil")
Call selectFile( workspace, CetElt.NativePath, “”)

' Autre mthode via Cde Shell :
' Dim CdeShell as New Shell
' CdeShell.Execute "open -R " + CetElt.ShellPath
' TampNbre = CdeShell.ErrorCode
' TampText = CdeShell.Result
' CdeShell.Close

' Ancienne mthode via AppleScript :
' CetElt.Parent.Launch ' Launch le dossier parent donc l'ouvre dans le Finder, et ne place que cette fentre au 1er plan, pas toutes celles du Finder comme
'  Activate d'AppleScript. Mais le Reveal d'AppleScript ci-dessous ne fait qu'ouvrir la fentre du dossier, a ne la place pas au 1er plan
' RevealThisItem(CetElt.NativePath) ' .ShellPath_fAS) ' Mieux que ci-dessus, en plus d'ouvrir la fentre du dossier, a slectionne l'lment dans la fentre, n'existe pas dans RealBasicEn

#Else ’ Windows ou Linux
CetElt.Parent.Launch ’ Launch le dossier parent donc l’ouvre dans le Finder

#EndIf
[/code]

Edit : I copy it from this forum.