Skip to content

Instantly share code, notes, and snippets.

@nanwang2016
Last active August 5, 2020 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nanwang2016/bb87644534a44b457250409b147d9eda to your computer and use it in GitHub Desktop.
Save nanwang2016/bb87644534a44b457250409b147d9eda to your computer and use it in GitHub Desktop.
using System.IO;
namespace TestFile
{
class Program
{
//The text file's path is stored in 'filename'
static string filename = @"C:\Users\Nan\source\repos\Example.txt";
static void Main(string[] args)
{
static void ReadFile()
{
FileStream fs = null;
try
{
fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
var b1 = fs.ReadByte();
var c1 = (char)b1;
}
finally
{
//File is closed
fs?.Close();
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment