# Displaying a file on disk

**URL:** <https://forum.xojo.com/t/displaying-a-file-on-disk/53085>\
**Category:** General\
**Created:** [April 4, 2020, 9:35am UTC](https://forum.xojo.com/t/displaying-a-file-on-disk/53085 "2020-04-04T09:35:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [April 4, 2020, 9:35am UTC](https://forum.xojo.com/t/displaying-a-file-on-disk/53085/1 "2020-04-04T09:35:44Z")

</div>

I set that feature to a newly added window and noticed that the .Parent folder is opened, but my file is not selected.

Any hint to how I can achieve that (Linux, macOS, Windows) ?

Actual code (f is the item to reval):

` If f <> Nil And f.Exists Then
    f.Parent.Launch
  End If`

PS: Reveal in AppleScript works fine (in the Scrip Editor).

---

<div class="post-metadata">

**Author:** ![Sam\_Rowlands](https://forum.xojo.com/user_avatar/forum.xojo.com/sam_rowlands/32/265_2.png) [@Sam\_Rowlands](https://forum.xojo.com/u/Sam_Rowlands)\
**Post date:** [April 4, 2020, 10:35am UTC](https://forum.xojo.com/t/displaying-a-file-on-disk/53085/2 "2020-04-04T10:35:28Z")

</div>

Here’s the code for the macOS, include it in a module and then call it with `folderitem.showInFinder`.

[code]Public Sub showInFinder(extends f as folderitem)  
#if TargetMacOS then  
// — Created for the forum, April the 4th 2020 by Sam Rowlands  
declare function NSClassFromString lib “Foundation” ( className as CFStringRef ) as integer  
declare function NSMutableArrayWithCapacity lib “AppKit” selector “arrayWithCapacity:” ( NSMutableArrayClass as integer, capacity as integer ) as integer  
declare sub NSMutableArrayAddObject lib “AppKit” selector “addObject:” ( NSMutableArray as integer, objectInstance as integer )  
declare function NSUrlfileURLWithPathIsDirectory lib “AppKit” selector “fileURLWithPath:isDirectory:” ( NSURLClass as integer, path as CFStringRef, folder as boolean ) as integer  
declare function NSWorkspaceSharedWorkspace lib “AppKit” selector “sharedWorkspace” ( NSWorkspaceClass as integer ) as integer  
declare sub NSWorkspaceActivateFileViewerSelectingURLs lib “AppKit” selector “activateFileViewerSelectingURLs:” ( shrdWorkSpace as integer, inUrls as integer )

```
Dim fileArray as integer = NSMutableArrayWithCapacity( NSClassFromString( "NSMutableArray" ), 1 )
NSMutableArrayAddObject( fileArray, NSUrlfileURLWithPathIsDirectory( NSClassFromString( "NSURL" ), f.nativePath, f.directory ) )
NSWorkspaceActivateFileViewerSelectingURLs( NSWorkspaceSharedWorkspace( NSClassFromString( "NSWorkspace" ) ), fileArray )

```

#endif  
End Sub  
[/code]

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [April 4, 2020, 10:41am UTC](https://forum.xojo.com/t/displaying-a-file-on-disk/53085/3 "2020-04-04T10:41:29Z")

</div>

Ouch ! Thank you Sam.

Any taker for Windows ?

---

<div class="post-metadata">

**Author:** ![Jeff\_Tullin](https://forum.xojo.com/user_avatar/forum.xojo.com/jeff_tullin/32/693_2.png) [@Jeff\_Tullin](https://forum.xojo.com/u/Jeff_Tullin)\
**Post date:** [April 4, 2020, 12:10pm UTC](https://forum.xojo.com/t/displaying-a-file-on-disk/53085/4 "2020-04-04T12:10:24Z")

</div>

> [@](#):
>
> Any taker for Windows ?

```auto
Myfile.parent.launch
```

?

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [April 4, 2020, 1:11pm UTC](https://forum.xojo.com/t/displaying-a-file-on-disk/53085/5 "2020-04-04T13:11:32Z")

</div>

> [@482475:@Jeff Tullin](#):
>
> ?

I have to fire Windows (VirtualBox) and check

Apparently, it does not works. I will check a second time.

I confirm (or too low memory condition): nothing is done. Even when I close the Explorer’s window, nothing happens.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [April 29, 2021, 4:20pm UTC](https://forum.xojo.com/t/displaying-a-file-on-disk/53085/6 "2021-04-29T16:20:44Z")

</div>


