rendered paste body// created on 6/26/2006 at 2:39 PM
// Hello World! : hello.cs
// Goal: construct html file
using System;
using System.IO;
class Hello {
static bool reload_categories() {
FileStream outfile; // file to write to
try {
outfile = new FileStream("config.txt", FileMode.OpenOrCreate, FileAccess.Write);
} catch(UnauthorizedAccessException exc) {
Console.WriteLine(exc.Message);
return false;
}
StreamWriter sw = new StreamWriter(outfile);
sw.Write(File.GetLastWriteTime("categories.txt").ToString()+'\n');
sw.Close();
outfile.Close();
return true;
}
static void Main() {
TextReader infile;
try {
infile = new StreamReader("test.txt"); // file to read from
} catch(FileNotFoundException exc) {
Console.WriteLine(exc.Message);
return;
}
TextReader categ;
try {
categ = new StreamReader("categories.txt"); // config file to read from
} catch(FileNotFoundException exc) {
Console.WriteLine(exc.Message);
return;
}
TextReader config;
try {
config = new StreamReader("config.txt"); // config file to read from
} catch(FileNotFoundException exc) {
if (!reload_categories())
return;
}
DateTime date_categories = File.GetLastWriteTime("categories.txt");
while (config.Peek() != -1) // reading config file to see if categories.txt has changed
{
String line = config.ReadLine();
if (date_categories.Equals(DateTime.Parse(line)))
if (!reload_categories())
return;
}
FileStream outfile; // file to write to
try {
outfile = new FileStream("test.html", FileMode.OpenOrCreate, FileAccess.Write);
} catch(UnauthorizedAccessException exc) {
Console.WriteLine(exc.Message);
return;
}
//date_categories
Console.WriteLine(date_categories);
// Create a new stream to write to the file
StreamWriter sw = new StreamWriter(outfile);
Console.WriteLine ("Hello, World!");
Console.WriteLine ("This shiznit actually works!");
while (infile.Peek() != -1) // reading file to write in formatted html to file
{
String line = infile.ReadLine();
Console.WriteLine(line);
sw.Write(line+'\n');
}
// Close StreamWriter & files
sw.Close();
outfile.Close();
infile.Close();
categ.Close();
}
}