# SetFolder

## Description

Only two folders are accessible to your AGK app; the read folder and the write folder. The read folder is the location of your executable and includes the media folder. The write folder (which also has read permission), is located in a platform safe location and is different depending on the device. On Windows, for example, the default write location is C:\Users\username\AppData\AGKApps\appName (By default this is a hidden folder on Windows and you may have to show hidden files to see it). These are your root folders. Any files created/written using OpenToWrite will be saved into the write folder. For simplicity, AGK merges these two read and write folders into a single command set. What this means is that when you attempt to open or load a file, AGK will first look in the write folder before looking in the read folder. Windows, Mac, and Linux have the unique command SetRawWritePath that allows you to overwrite this behavior, but is not recommended as it is not compatible with mobile platforms and users may even require administrator privileges. When using SetFolder, its behavior is what you'd expect from the CD command in the Windows or Linux console; It works from the current directory. For instance, if the current root read folder is C:\games\myApp\ then SetFolder("images") will put you in C:\games\myApp\images. Calling the command a second time SetFolder("backgrounds") will place you at C:\games\myApp\images\backgrounds\. There are two ways to return to the root path. The first is to call SetFolder("") using an empty string. The other is to preceed your path with a forward slash, SetFolder("/stuff"). This also applies to loading your files with other commands as well. Assume you're still located in the images\backgrounds folders and you want to load bk.png located in the root folder. You can simply say LoadImage("/bk.png"). Setting the path to a folder that does not exist and using OpenToWrite will create that folder in the write path. SetFolder does not check that the folder exists, it just sets an internal path that will be used in the next file command. By default, AGK calls SetFolder("media") as the first thing it does. This command returns 1 on success or 0 if you use an invalid path such as SetFolder("C:\"). Note: It is important to remember when setting paths to always use forward slashes instead of backslash. AGK will convert them into the appropriate file separator for the given platform.

## Definition

integer SetFolder( str )

int agk::SetFolder( const char* str )