using System;
namespace CAT
{
class MainClass
{
public static void Main (string[] args)
{
string path = @"E:\CAT\Name.txt";
if (!System.IO.File.Exists(path))
{
System.IO.File.Create(path);
System.IO.TextWriter tw = new System.IO.StreamWriter(path);
tw.WriteLine("File Created!");
tw.Close();
} else if (System.IO.File.Exists(path)){
System.IO.TextWriter tw = new System.IO.StreamWriter(path, true);
tw.WriteLine("New Boot.");
tw.Close();
}
Console.WriteLine("Directory System - Copyright 2016 xxxxCo.");
Console.WriteLine("What is your surname?");
string Surname = Console.ReadLine();
System.IO.TextWriter fileEnter = new System.IO.StreamWriter(path);
fileEnter.WriteLine(Surname);
Console.WriteLine ("What is your first name?");
string fn = Console.ReadLine ();
fileEnter.WriteLine(fn);
Console.WriteLine ("Hello " + fn + " " + Surname);
Console.Read();
Console.Clear();
Console.WriteLine("Directory System - Copyright 2016 xxxxCo.");
Console.WriteLine ("Year?");
string year = Console.ReadLine();
// New file created for year and meta data
string yearpath = @"E:\CAT\Year.txt";
if (!System.IO.File.Exists(yearpath))
{
System.IO.File.Create(yearpath);
System.IO.TextWriter tw = new System.IO.StreamWriter(yearpath);
tw.WriteLine("File Created!");
tw.Close();
}
else if (System.IO.File.Exists(yearpath))
{
System.IO.TextWriter tw = new System.IO.StreamWriter(yearpath, true);
tw.WriteLine("New Boot.");
tw.Close();
}
// new text writer created for year data
System.IO.TextWriter fileEnterYear = new System.IO.StreamWriter(yearpath);
fileEnterYear.WriteLine(year + " " + fn.Substring(0, 1) + Surname.Substring(0, 1));
Console.Read();
}
}
Please excuse my horrible organisation, I whipped this up as a test program since I just downloaded Xamarin Studio. Each of the files are created within their respective locations but then neither are written to. Please help me to fix this as I can't see what my error is. Many Thanks