How can I store and read dialogue?

How can I store dialogue so that it could be read for a kinetic (linear) Visual Novel type of game in XNA/MonoGame?

I'm currently using a .txt file, but I noticed that I can't read from a specific line using the System.IO.StreamReader class.

• The irony. An Alex helping another Alex. – The Mattbat999 Jul 2 '18 at 14:33

You'll want to use TitleContainer.OpenStream in place of the stream reader.

The reason they do it differently in XNA / MonoGame is for cross platform compatibility. Essentially, the TitleContainer abstracts away the details about how to read the file on whatever platform you're targeting.

There's also two other things you'll need to be aware of:

1. When you're loading raw content that isn't processed with the Content Pipeline tool, you'll need to set the properties of the file in Visual Studio to Content and Copy if newer.
2. You'll need to use the path and file extension (not just the name like you would with Content.Load

For example:

using (var stream = TitleContainer.OpenStream("Content/data.txt"))

• The using statement is shorthand for a try finally block. It's designed to safely dispose of the stream when it's no longer in use even if exceptions are thrown. In some circumstances you might want call Dispose yourself (e.g. if you want to hang on to a reference to the stream for more than one method call) but designing your code this way often makes things more complex. My advice, start with the simplest thing that works. – craftworkgames Sep 5 '17 at 10:35