> For the complete documentation index, see [llms.txt](https://docs.flatredball.com/flatredball/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flatredball.com/flatredball/api/flatredball/io/filemanager/savetext.md).

# SaveText

### Introduction

The SaveText function is a function that can be used to easily save the contents of a string to a .txt file. This function will overwrite previously-created .txt files if an existing file name is passed, so be careful calling this method.

### Code Example

The following code creates a string, saves it to a .txt file, then opens that file.

```
System.Text.StringBuilder builder = new System.Text.StringBuilder();

builder.AppendLine("Why is FlatRedBall so great?  Let me count the reasons...");

// Stop at 100 to prevent an infinite loop :)
for (int i = 1; i < 100; i++)
{
    builder.AppendLine(i.ToString());
}

string fileToSave = FileManager.UserApplicationData + @"\temp.txt";

FileManager.SaveText(builder.ToString(), fileToSave);

System.Diagnostics.Process.Start(fileToSave);
```

![SaveText.png](/files/bNHtr7Uk6sAJEG8ZngFG)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.flatredball.com/flatredball/api/flatredball/io/filemanager/savetext.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
