> For the complete documentation index, see [llms.txt](https://docs.flatredball.com/gum/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flatredball.com/gum/code/files-and-fonts/content-using-embedded-resources.md).

# Content Using Embedded Resources

## Introduction

While some platforms (such as Windows) provide direct access to the file system, access to files on platforms like iOS and Android is limited.

Content loading can be performed using embedded resources to standardize file access across all platforms. This section discusses how to use embedded resources in SkiaGum.

## Embedded Resource Setup

Before loading a resource, SkiaGum projects must first be set up to load from embedded resource. Gum must know two pieces of information before content can be loaded:

1. Which project contains the embedded resources to be loaded
2. How to modify a resource path (optional, but required if using generated code)

Before performing this initialization, you must decide where you will store your content. For example, consider a project which stores all of its SVG files in a `GumProject/Resources` folder.

<figure><img src="/files/mx9pkprxzTe1aIVtLdmS" alt=""><figcaption><p>Resources folder in a GumProject folder</p></figcaption></figure>

{% hint style="info" %}
If you are using a Gum (.gumx) project, adding resource files relative to the Gum project is recommended since it keeps your project portable.
{% endhint %}

When using generated code, Gum generates all file loads relative to the .gumx location, so we need to tell the Gum runtime to use this as its relative path.

To do this, add the following code to where you initialize your code project, such as the CreateMauiApp function:

```csharp
SkiaResourceManager.CustomResourceAssembly = typeof(MauiProgram).Assembly;
SkiaResourceManager.AdjustContentName = (contentName) =>
{
    return "MauiSkiaGum.GumProject." + contentName;
};
```

Notice that resource loading uses the period separator for paths, so the adjusted content name should take form of `YourProjectName.Subfolder.Subfolder2.AdditionalSubFolder`.

## Marking Files as Embedded Resource

To mark your files as embedded resource in Visual Studio:

1. Right-click on a file and select Properties
2. Change the `Build Action` to `Embedded resource` in the Properties tab.

<figure><img src="/files/967JPSdZmu4WguL82HrX" alt=""><figcaption></figcaption></figure>

For simpler maintenace, this can be changed to a wildcard in the .csproj file:

```xml
<ItemGroup>
  <EmbeddedResource Include="GumProject\Resources\**\*" />
</ItemGroup>
```

## Generated Code Content Loading

If embedded resource content loading is set up correctly, then generated code will correctly load files.

Note that generated code does not assume embedded resource content loading. For example, the following block of generated code shows how an SVG SourceFile is assigned:

```csharp
this.SvgInstance.SourceFile = @"Resources\gum-logo-reverse.svg";
```

Notice that in this case the source file uses a slash separator, but embedded resources internally use a period character for separators. Internally Gum automatically handles this difference so no changes are needed in generated code.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.flatredball.com/gum/code/files-and-fonts/content-using-embedded-resources.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
