I have tried the following code in a class which I added to the WebForm1.cs called TextFromFile...it compiles but does not
show my text file in a browser when I do a start without debugging.
using System;
using System.IO;
namespace WebApplication4
{
/// <summary>
///
/// </summary>
public class TextFromFile
{
private const string FILE_NAME = "blah.txt";
public static void Main(String[] args)
{
if (!File.Exists(FILE_NAME))
{
Console.WriteLine("{0} does not exist.", FILE_NAME);
return;
}
StreamReader sr = File.OpenText(FILE_NAME);
String input;
while ((input=sr.ReadLine())!=null)
{
Console.WriteLine(input);
}
Console.WriteLine ("The end of the stream has been reached.");
sr.Close();
}
}
//
// TODO: Add constructor logic here
//
}
|