# Reading text files

**URL:** https://talk.remobjects.com/t/reading-text-files/22432
**Category:** Oxygene
**Created:** [June 28, 2020, 7:32am UTC](https://talk.remobjects.com/t/reading-text-files/22432 "2020-06-28T07:32:02Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![garry.pettet](https://talk.remobjects.com/user_avatar/talk.remobjects.com/garry.pettet/32/12917_2.png) [@garry.pettet](https://talk.remobjects.com/u/garry.pettet)
#### Post date: [June 28, 2020, 7:32am UTC](https://talk.remobjects.com/t/reading-text-files/22432/1 "2020-06-28T07:32:02Z")

</div>

Assume I have a simple text file: `/Users/garry/Desktop/test.txt`.

How would I read the entire contents of that file into a string using C# and RTL?

I’ve been looking at the `FileStream` documentation but I don’t see a constructor that takes a file path.

With .NET you’d do something like:

```auto
StreamReader sr = new StreamReader("`/Users/garry/Desktop/test.txt");
string source = sr.ReadToEnd();

```

---

<div class="post-metadata">

### Author: ![JohnMoshakis](https://talk.remobjects.com/user_avatar/talk.remobjects.com/johnmoshakis/32/2286_2.png) [@JohnMoshakis](https://talk.remobjects.com/u/JohnMoshakis)
#### Post date: [June 28, 2020, 1:18pm UTC](https://talk.remobjects.com/t/reading-text-files/22432/2 "2020-06-28T13:18:52Z")

</div>

The File Class

> <https://github.com/remobjects/RTL2/blob/master/Source/File.pas>

File.ReadText and File.ReadLines
