Reveal file in Explorer

The code below simply opens the owning folder, it does not select the passed item, as I suspected:

[code] Dim f As FolderItem

f = GetFolderItem(“Network Interfaces.app”) // Beside the running project

showurl f.parent.urlpath[/code]

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]

I prefer my Mac

Dim f As FolderItem
f= SpecialFolder.Pictures // or other folder
If f <> Nil Then
f.Launch
End If

Harry

but it does not highlight the file as requested by the op. :frowning:

Here’s the SHOpenFolderAndSelectItems version, tested in 32 and 64. It will allow you to pop open a Windows Explorer with multiple files selected.

https://www.dropbox.com/s/q6eog4rkta8l45e/SHOpenFolderAndSelectItems.xojo_binary_project?dl=0

updated my blog post with a link to your code

[quote=455369:@]Here’s the SHOpenFolderAndSelectItems version, tested in 32 and 64. It will allow you to pop open a Windows Explorer with multiple files selected.

https://www.dropbox.com/s/q6eog4rkta8l45e/SHOpenFolderAndSelectItems.xojo_binary_project?dl=0[/quote]

in that code what is COM.SIZEOF_PTR ?

When i try to compile I get “this Item does not exist”

Thanks
Karen

Its used to space things correctly for 32/64 bit, its a value that changes from 4 to 8 depending on if you’re compiling for 32 or 64 bit (the size of a pointer, which changes), you can use a const inside a #If Target32Bit if its not in that edition of xojo:

At the top of that method put:

#If Target32Bit Const SIZEOF_PTR = 4 #Else Const SIZEOF_PTR = 8 #EndIf

Then remove the COM. infront of the two lines which have COM.SIZEOF_PTR so it uses the const instead.

Out of interest, which version of Xojo are you trying this on as if the #if doesn’t work on that edition, just replace it with a 4 or 8 depending on your target.

[quote=458856:@]Its used to space things correctly for 32/64 bit, its a value that changes from 4 to 8 depending on if you’re compiling for 32 or 64 bit (the size of a pointer, which changes), you can use a const inside a #If Target32Bit if its not in that edition of xojo:

At the top of that method put:

#If Target32Bit Const SIZEOF_PTR = 4 #Else Const SIZEOF_PTR = 8 #EndIf

Then remove the COM. infront of the two lines which have COM.SIZEOF_PTR so it uses the const instead.

Out of interest, which version of Xojo are you trying this on as if the #if doesn’t work on that edition, just replace it with a 4 or 8 depending on your target.[/quote]

Thanks!

I’m not sure… On my mac when I tried to complier for Windows in was either 2018r3 0r 2019R1.1… When I tried in parallels with Windows 7 it was some older version… maybe from 2015 or 2016… I can tell you this evening after I get home what version it was.

-Karen