# SaveToFile(string)

> Save GraphicsStateCollection to disk.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine.Experimental.Rendering](/engine/6000.3/script-reference/unityengine/experimental/rendering.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
public bool SaveToFile(string filePath)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Output location of GraphicsStateCollection serialized data.

### Returns

| Type                                                          | Description                                                     |
| ------------------------------------------------------------- | --------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | Returns true if collection successfully saved, false otherwise. |

### Remarks

The file extension of GraphicsStateCollection is \*.graphicsstate.

```csharp
using UnityEngine;
using UnityEngine.Experimental.Rendering;

public class SaveToFileExample : MonoBehaviour
{
    public GraphicsStateCollection graphicsStateCollection;
    public string filePath;

    void Start()
    {
        graphicsStateCollection = new GraphicsStateCollection();
        graphicsStateCollection.BeginTrace();
    }

    void OnDestroy()
    {
        graphicsStateCollection.EndTrace();
        graphicsStateCollection.SaveToFile(filePath);
    }
}
```

Additional Resources: [GraphicsStateCollection.LoadFromFile](/engine/6000.3/script-reference/unityengine/experimental/rendering/graphicsstatecollection/loadfromfile.md), [GraphicsStateCollection.SendToEditor](/engine/6000.3/script-reference/unityengine/experimental/rendering/graphicsstatecollection/sendtoeditor.md).
