# DownloadHandlerFile

> Download handler for saving the downloaded data to file.

## Definition

* **Type:** Class
* **Namespace:** [UnityEngine.Networking](/engine/6000.6/script-reference/unityengine/networking.md)
* **Assembly:** UnityEngine.UnityWebRequestModule
* **Inherits from:** [DownloadHandler](/engine/6000.6/script-reference/unityengine/networking/downloadhandler.md)
* **Implements:** [IDisposable](https://learn.microsoft.com/dotnet/api/system.idisposable)

```csharp
public sealed class DownloadHandlerFile : DownloadHandler, IDisposable
```

## Remarks

This specialized download handler writes all downloaded bytes directly to file. This can help avoid high memory usage.

You can't retrieve data from this download handler. Instead, you work with the resulting file when the download is complete.

## Examples

```csharp
using System.Collections;
using System.IO;
using UnityEngine;
using UnityEngine.Networking;

public class FileDownloader : MonoBehaviour {

    void Start () {
        StartCoroutine(DownloadFile());
    }

    IEnumerator DownloadFile() {
        var uwr = new UnityWebRequest("https://unity3d.com/", UnityWebRequest.kHttpVerbGET);
        string path = Path.Combine(Application.persistentDataPath, "unity3d.html");
        uwr.downloadHandler = new DownloadHandlerFile(path);
        yield return uwr.SendWebRequest();
        if (uwr.result != UnityWebRequest.Result.Success)
            Debug.LogError(uwr.error);
        else
            Debug.Log("File successfully downloaded and saved to " + path);
    }
}
```

## Constructors

| Constructor                                                                                                                                                                | Description                                                                         |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| [DownloadHandlerFile(System.String)](/engine/6000.6/script-reference/unityengine/networking/downloadhandlerfile/ctor.md#downloadhandlerfile\(string\))                     | Creates a new instance and a file on disk where downloaded data will be written to. |
| [DownloadHandlerFile(System.String,System.Boolean)](/engine/6000.6/script-reference/unityengine/networking/downloadhandlerfile/ctor.md#downloadhandlerfile\(string-bool\)) | Creates a new instance and a file on disk where downloaded data will be written to. |

## Properties

| Property                                                                                                             | Description                                                                                              |
| -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| [removeFileOnAbort](/engine/6000.6/script-reference/unityengine/networking/downloadhandlerfile/removefileonabort.md) | Should the created file be removed if download is aborted (manually or due to an error). Default: false. |

## Inheritance

**Inherited Members:**

* [DownloadHandler.Dispose()](/engine/6000.6/script-reference/unityengine/networking/downloadhandler/dispose.md)
* [DownloadHandler.isDone](/engine/6000.6/script-reference/unityengine/networking/downloadhandler/isdone.md)
* [DownloadHandler.error](/engine/6000.6/script-reference/unityengine/networking/downloadhandler/error.md)
* [DownloadHandler.nativeData](/engine/6000.6/script-reference/unityengine/networking/downloadhandler/nativedata.md)
* [DownloadHandler.data](/engine/6000.6/script-reference/unityengine/networking/downloadhandler/data.md)
* [DownloadHandler.text](/engine/6000.6/script-reference/unityengine/networking/downloadhandler/text.md)
