> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SaveToFile Method of the ImageDocument Object

This method saves the contents of the [**ImageDocument**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imagedocument.md) object into a file. The file is saved in a format which cannot be viewed in any external program. The **ImageDocument** object saved using this method can be opened with the help of the [**IEngine::LoadImageDocFromFile**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/engine-loadimagedocfromfile.md) method only.

## Syntax

```vb Visual Basic .NET theme={null}
Sub SaveToFile(fileName As String)
```

```cpp C++ theme={null}
HRESULT SaveToFile(
   BSTR fileName
);
```

## Parameters

**fileName**

\[in] This parameter stores the full path to the file. For example, "C:\MyPic.imageDoc". If this file already exists, it is overwritten without prompt.

## Return values

This method has no specific return values. It returns the [standard return values of ABBYY FlexiCapture SDK functions](https://docs.abbyy.com/flexi-capture/sdk/api-reference/errorcodes.md).

## Remarks

This method is not suitable for saving images, as it saves the contents of the **ImageDocument** object in a format not suitable for viewing. It is designed for situations when it is not possible to use the [**IImageDocument::SaveTo**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imagedocument-saveto.md) method which saves the object's contents into a folder on disk.

To save an image in a format suitable for viewing, use the [**IImage::WriteToFile**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/image-writetofile.md) method.

## See also

[**ImageDocument**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/imagedocument.md)

[**IEngine::LoadImageDocFromFile**](https://docs.abbyy.com/flexi-capture/sdk/api-reference/engine-loadimagedocfromfile.md)
