I have a simple program where I write 6 of 7 numbers to a text file. Logically everything seems to be fine.
However the numbers are not written to the file as expected.
Random random = new Random();
Console.WriteLine("Please enter the name of the numbers file");
string fileLotto = Console.ReadLine();
//creating the lotto file
FileStream fs = new FileStream("../../" + fileLotto + ".txt", FileMode.OpenOrCreate, FileAccess.Write);
BufferedStream bs = new BufferedStream(fs);
Console.WriteLine("File created");
fs.Close();
StreamWriter sw = new StreamWriter("../.." + fileLotto + ".txt");
for(int i = 0; i < 6; i++)
{
for(int j = 0; j < 7; j++)
{
//Console.Write(random.Next(1, 49));
sw.Write(random.Next(1, 49) + " " );
}
sw.WriteLine();
}
sw.Close();
The file was created, however no numbers were written to the file...advice perhaps as to why?