# LoadBytes(byte[], Action<bool>)

> Loads the index asynchronously (in another thread) from a binary buffer.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor.Search](/engine/6000.7/script-reference/unityeditor/search.md)
* **Assembly:** UnityEditor

> **Warning:**
>
> **Deprecated.** This method is no longer supported. The content of the indexer is automatically saved on disk.

```csharp
public bool LoadBytes(byte[] bytes, Action<bool> finished)
```

### Parameters

**** (\[byte\[]]\(https\://learn.microsoft.com/dotnet/api/system.byte)): Binary buffer containing the index representation.**** (\[Action\<bool>]\(https\://learn.microsoft.com/dotnet/api/system.action)): Callback that triggers when the index is fully loaded. The callback parameters indicates if loading was succesful.

### Returns

| Type                                                          | Description                                                                                                        |
| ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | Returns false if the index is of an unsupported version or if there was a problem initializing the reading thread. |

### Examples

```csharp
using System.IO;
using UnityEditor;
using UnityEditor.Search;
using UnityEngine;

static class Example_SearchIndexer_LoadBytes
{
    const string tempIndexPath = "Temp/LoadBytes.db";

    [MenuItem("Examples/SearchIndexer/LoadBytes")]
    public static void Run()
    {
        var si = new SearchIndexer("SearchIndexerExample", FileUtil.GetUniqueTempPathInProject());
        si.Start();
        var di = si.AddDocument("document 1");
        si.AddNumber("test", 2, 0, di);
        si.Finish(() =>
        {
            File.WriteAllBytes(tempIndexPath, si.SaveBytes());
            // Dispose of the SearchIndexer when you are done with it.
            si.Dispose();
            ReloadIndex();
        });
    }

    private static void ReloadIndex()
    {
        var indexBytes = File.ReadAllBytes(tempIndexPath);
        var si = new SearchIndexer("SearchIndexerExample2", FileUtil.GetUniqueTempPathInProject());

        // Load the search index from a binary stream.
        si.LoadBytes(indexBytes, (success) =>
        {
            Debug.Assert(success);
            Debug.Log($"Index loaded from {indexBytes} bytes");
            // Dispose of the SearchIndexer when you are done with it.
            si.Dispose();
        });
    }
}
```
