Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] SetFolder and GetDocumentsPath()

Author
Message
Hubert BAYRE
7
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 23rd May 2019 07:26 Edited at: 23rd May 2019 07:58
Hi !

Is there a way to write a function as 'SetFolder' but from any path ? (outside the read and write default app folder)

i wan't store my external data (some sounds and images) and next use loadimage or loadsound with relative path from GetDocumentsPath() + "MyFolder"

Many thanks.

The author of this post has marked a post as an answer.

Go to answer

blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 23rd May 2019 07:57
SetFolder() is designed to be used in sandbox mode (Only allowing access in the media and C:\Users\your_name\AppData\Local\AGKApps\your_app directories) . If you want to use other directories then use the "raw:" prefix when accessing a file

From the doco
Quote: "If you want to access files outside of the read and write folders you can use the normal file commands such as OpenToRead with a "raw:" file path, see that command for more details. To access folders outside the read and write folders you can use the OpenRawFolder commands. "
Hubert BAYRE
7
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 23rd May 2019 07:59
i've just edited my previous post after reading the doc. Have you an idea ?
Hubert BAYRE
7
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 23rd May 2019 08:03 Edited at: 23rd May 2019 08:12
Before the data folder was inside the 'sandbox' path so :

SetFolder ("/")
SetFolder("MyFolder")
SetFolder ("Images")
LoadImage ("toto.png")
..
...
LoadImage ("toto2.png")
LoadImage ("toto3.png")

But now i decide to change this folder to GetDocumentsPath() + "MyFolder"

So imagine the numbers of LoadImage path to change ! (Huge project) !

LoadImage ("RAW:" + GetDocumentsPath() + "MyFolder/images" + "toto2.png")
LoadImage ("RAW:" + GetDocumentsPath() + "MyFolder/images" + "toto3.png")

...

If a can use this :

MySetFolder (GetDocumentsPath() + "MyFolder/images")
LoadImage ("toto.png")
..
...
LoadImage ("toto2.png")
LoadImage ("toto3.png")

i'm affraid that's not possible !
Hubert BAYRE
7
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 23rd May 2019 08:15 Edited at: 23rd May 2019 08:16
Global MyPath as String

MyPath = GetDocumentsPath() + "MyFolder/images/"

LoadImage (MyPath + "toto.png")
..
...
LoadImage (MyPath + "toto2.png")
LoadImage (MyPath + "toto3.png")

?

Is there another method ?
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 23rd May 2019 08:26
This post has been marked by the post author as the answer.
Maybe just create you own function

Hubert BAYRE
7
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 23rd May 2019 08:47
Thanks nice idea !

Do you know an GetFirstFile() alternative with Raw files




blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 23rd May 2019 08:56
Hubert BAYRE
7
Years of Service
User Offline
Joined: 21st Oct 2017
Location: France
Posted: 23rd May 2019 09:08
Many thanks blink0k !

Login to post a reply

Server time is: 2024-11-22 21:31:53
Your offset time is: 2024-11-22 21:31:53