Getting content of text file - CSharp System.IO

CSharp examples for System.IO:Text File

Description

Getting content of text file

Demo Code


using System.Windows.Forms;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;/*from www .j  a v  a2 s. co  m*/
using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;

public class Main{
        public static List<string> GettingManual()
        {
            FileStream fs = new FileStream("Manual.txt", FileMode.Open, FileAccess.Read);
            StreamReader sr = new StreamReader(fs);
            List<string> manual = new List<string>();
            string s = sr.ReadLine();
            while (s != null)
            {
                manual.Add(s);
                s = sr.ReadLine();
            }
            sr.Dispose();
            fs.Dispose();
            return manual;
        }
}

Related Tutorials