I try to make a program that read the content from a .txt file and then print the content using Console.WriteLine() .I add the file that I want to read to my project .
This is the content of my file:
Hello.txt:
Hello World!!!!!!!!!!!!!
And this is my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace FileIO
{
class Program
{
static void Main(string[] args)
{
FileStream file = new FileStream("HELLO.txt",FileMode.Open,FileAccess.Read);
StreamReader str = new StreamReader(file);
string hello = str.ReadToEnd();
Console.WriteLine(hello);
Console.ReadLine();
str.Close();
}
}
}
My problem is that when i run the project is nothing appearing .
Please , say to my which is the problem and i will be thankful .