Opening specific folder in windows explorer

Hey all,

Could someone possibly help me? I am trying to have a button open the explorer to specific path, Namely

%userprofile%\AppData\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets

I am fairly new to xojo and this is my first attempt in fooling around with folders and such. Could someone possibly guide me on how to achieve this?

Many thanks!

You could try

dim f as folderitem
f = newfolderitem(ā€œ%userprofile%\AppData\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assetsā€,FolderItem.PathModes.Native)

f.open

If the user is yourself, build up a folderitem using.child

dim f as folderitem
f = specialfolder.applicationdata   // this is userprofile/AppData
if f <> nil and f.exists then
f = f.child("Local")
end if

if f <> nil and f.exists then
f = f.child("Packages")
end if

if f <> nil and f.exists then
f = f.child("Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy")
end if
if f <> nil and f.exists then
f = f.child("LocalState")
end if
if f <> nil and f.exists then
f = f.child("Assets")
end if

f.open

If the user is not yourself, you probably dont have permission to look there.
That w5n1h2txyewy looks pretty specific - Im not sure it will be ā€˜the same for everyoneā€™

I havent added any error handling to the IF statements - obviously they all need an ā€˜elseā€™ because any of them could fail.

Finally, you may find that the best way to find the path is to read a registry setting, but I have no idea what that folder is about.

1 Like

Hi Robin,

Interested to use an Open Dialog ?

If so, read there:
http://documentation.xojo.com/api/user_interface/desktop/openfiledialog.html

And there, in the See Also entry, you wil find a link to a Save Dialog (between others).

1 Like

This is perfect Jeff, It is pretty specific but it is for personal use to take me to where Microsoft store their lock-screen backgrounds with ease :grin: It is also to teach me more about folder items etcā€¦ Thank you for the help!

@Emile_Schwarz

I have looked through the documentation but couldnā€™t understand most of it. I am still very new to Xojo but I am learning!

Thank you :slightly_smiling_face: