Using System.IO File properties to write to and read from a text file

<< Click to Display Table of Contents >>

Navigation:  NinjaScript > Educational Resources > Reference Samples > Indicator >

Using System.IO File properties to write to and read from a text file

Previous page Return to chapter overview Next page

Using Stream objects can be cumbersome when you only want to write/read a small amount of data. Fortunately, you can handle this operation with another method. Keep in mind that in exchange for the convenience you will lose some performance.

 

Key concepts in this example

Creating and appending a text file with Open-High-Low-Close data and date stamps
Determining current day Open-High-Low-Close after reading data from the text file

 

Important related documentation

File.AppendAllText()
File.ReadAllText()

Other methods and properties of interest include:

File.ReadAllLines()
File.WriteAllLines()

 

Import instructions

1.Download the file contained in this Help Guide topic to your PC desktop
2.From the Control Center window, select the menu Tools > Import > NinjaScript
3.Select the downloaded file

 

SampleFileReadWrite_NT8.zip