Category >
CSHARP
|| Published on :
Sunday, October 4, 2020 || Views:
791
||
FileStream class
Here Pawan Kumar will explain how to use the FileStream class
using System;
using System.IO;
namespace Demo
{
class Program
{
static void Main(string[] args)
{
FileStream src = new
FileStream(@"C:\test.html", FileMode.Open, FileAccess.Read);
int numBytes = (int)src.Length;
int i = 0;
byte[] bytes = new byte[src.Length];
Console.WriteLine("Number of bytes in the file " + numBytes);
src.Read(bytes, i, numBytes);
string result = System.Text.Encoding.UTF8.GetString(bytes);
Console.WriteLine(result);
Console.Read();
}
}
}