c# read file stream
using System;
using System.IO;
using System.Text;
namespace StreamReaderReadToEnd
{
class Program
{
static void Main(string[] args)
{
var path = @"C:\Users\Jano\Documents\thermopylae.txt";
using var fs = new FileStream(path, FileMode.Open, FileAccess.Read);
using var sr = new StreamReader(fs, Encoding.UTF8);
string content = sr.ReadToEnd();
Console.WriteLine(content);
}
}
}//this will get a string with all the text from the file
var fileText = File.ReadAllText(@"path\to\my\file.txt");
//this will get all of the lines of the file as an string[]
var fileLines = File.ReadAllLines(@"path\to\my\file.txt");
Also in C#:
- c# param exception
- c# how to take from a float
- mvc c# w3schools
- how to locate a specific element in a list c#
- c# send email
- how to detect if a key is pressed in c#
- c# read file stream
- create dropdown in datatable c# dynamically
- c# mongodb update multiple fields
- change sprite of gameobject unity
- non null array length
- c# index in select
- how to add a list to observablecollection in c#
- singleton unity
- unity assign button onclick
- what function is called just before the a script is ended c#
- textblock line break
- c# reflection create generic type
- iphone
- how to get specific length of row in matrix c#
- wpf label text in center
- c# list to string comma separated
- c# object clone
- c# method info extension