> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# File

> The FileTools toolkit enables Agents to read and write files on the local file system.

## Example

The following agent will generate an answer and save it in a file.

```python cookbook/91_tools/file_tools.py theme={null}
from agno.agent import Agent
from agno.tools.file import FileTools

agent = Agent(tools=[FileTools()])
agent.print_response("What is the most advanced LLM currently? Save the answer to a file.", markdown=True)
```

## Toolkit Params

| Parameter | Type | Default | Description |
| - | - | - | - |
| `base_dir` | `Path` | `None` | Specifies the base directory path for file operations |
| `enable_save_file` | `bool` | `True` | Enables functionality to save files |
| `enable_delete_file` | `bool` | `False` | Enables functionality to delete files |
| `enable_read_file` | `bool` | `True` | Enables functionality to read files |
| `enable_read_file_chunk` | `bool` | `True` | Enables functionality to read files in chunks |
| `enable_replace_file_chunk` | `bool` | `True` | Enables functionality to update files in chunks |
| `enable_list_files` | `bool` | `True` | Enables functionality to list files in directories |
| `enable_search_files` | `bool` | `True` | Enables functionality to search for files by name pattern |
| `enable_search_content` | `bool` | `True` | Enables functionality to search file contents (`search_content`) |
| `all` | `bool` | `False` | Enables all functionality when set to True |
| `expose_base_directory` | `bool` | `False` | Adds 'base\_directory' to the tool responses if set to True |
| `exclude_patterns` | `Optional[List[str]]` | noise dirs | fnmatch-style patterns skipped by `list_files`, `search_files`, and `search_content`. Pass `[]` to disable exclusion. Does not parse `.gitignore`. |
| `max_file_length` | `int` | `10000000` | Maximum decoded text length, measured in Python characters. Reading fails if the decoded content is longer. |
| `max_file_lines` | `int` | `100000` | Maximum number of lines to read from a file. Reading will fail if the file has more lines. |
| `line_separator` | `str` | `"\n"` | The separator to use when interacting with chunks. |

## Toolkit Functions

| Name | Description |
| - | - |
| `save_file` | Saves the contents to a file called `file_name` and returns the file name if successful. |
| `read_file` | Reads the contents of the file `file_name` and returns the contents if successful. |
| `read_file_chunk` | Reads a line range from the file `file_name` and returns the contents if successful. |
| `replace_file_chunk` | Partial replace of the contents of the file `file_name` |
| `delete_file` | Deletes the file `file_name` if successful. |
| `list_files` | Returns a list of files in the base directory |
| `search_files` | Finds files by name using an fnmatch-style `pattern`. |
| `search_content` | Searches file contents for a `query` within an optional `directory`, returning up to `limit` matches. |

## Developer Resources

* [Tools](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/tools/file.py)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.