---
url: /flow/guide/scripting-reference/functions/file/savetofile.md
---

# SaveToFile

## Declaration

`Procedure SaveToFile( const aContents, aFileName : string)`

`Procedure SaveWideStringToFile( const aContents : widestring; const aFileName : string)`

### Example

```pascal
procedure OnMapEvent(var Value:Variant);
var data : string;
begin
data := 'abcde'
  SaveToFile(data, 'c:\test.txt');
end;
```

## Description

Saves the string given by aContents as a file named aFileName. Also see [LoadFileToString](/flow/guide/scripting-reference/functions/file/loadfiletostring).

Use the WideString version to handle Unicode characters.

If a file with aFileName already exists then it will be overwritten if attributes and permissions allow (if not allowed then an Exception will be raised - see [Exceptions](/flow/guide/scripting-reference/exceptions)).
