menu_bookDocumentation

File System: Sandboxed Virtual Filesystems for Data Persistence

calendar_today May 20, 2026 schedule ~1 min read person PatrickJr verified 50

Standard .NET System.IO.File access is restricted in s&box. Instead, use the provided BaseFileSystem virtual filesystems that sandbox access to specific game directories.

Available File Systems

FileSystemPurposePath Example
FileSystem.DataPer-game data storagesbox/data/org/game/
FileSystem.MountedAggregate of all mounted content (core + game + dependencies)Read-only
FileSystem.OrganizationDataShared data across games in your orgsbox/data/org/

Reading and Writing Text

CSHARP
if ( !FileSystem.Data.FileExists( "player.txt" ) )
    FileSystem.Data.WriteAllText( "player.txt", "Hello, world!" );

var hello = FileSystem.Data.ReadAllText( "player.txt" );

Reading and Writing JSON

Only properties (not fields) are serialized by default:

CSHARP
public class PlayerData
{
    public int Level { get; set; }      // Serialized ✔️
    public int MaxHealth { get; set; }  // Serialized ✔️
    public string Username;             // NOT serialized ❌ (field, not property)

    public static void Save( PlayerData data )
    {
        FileSystem.Data.WriteJson( "player.json", data );
    }

    public static PlayerData Load()
    {
        return FileSystem.Data.ReadJson<PlayerData>( "player.json" );
    }
}

Key Points

Was this helpful?