I want to make a program that allows you to manipulate and manage information about
CDs that is stored in a text file. The file should save for each CD, author / group name, CD name, year of edit, publisher name, total time (in minutes) and number of tracks.
The if
does not work because?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string line;
int valor;
string input;
string[] names = new string[6];
Console.WriteLine("Escolha:\n1 - adicionar\n2 - Visualizar\n 3 - Sair");
input = Console.ReadLine();
valor = Int32.Parse(input);
if (valor == 1)
Console.WriteLine("Escreva o nome do autor/grupo, nome do CD, ano de edição, nome da editora, total de tempo e número de faixas: ");
for (int i = 0; i < 6; i++)
{
names[i] = Console.ReadLine();
}
StreamWriter SW = new StreamWriter(@"C:\Users\gabri\Desktop\trabalho.txt");
for (int i = 0; i < 6; i++)
{
SW.WriteLine(names[i]);
}
SW.Close();
if (valor == 2)
Console.WriteLine("FICHEIRO .txt: \n");
StreamReader reader = File.OpenText(@"C:\Users\gabri\Desktop\trabalho.txt");
while ((line = reader.ReadLine()) != null)
{
Console.WriteLine(line);
}
Console.ReadKey();
if (valor == 3)
Console.WriteLine("Adeus");
}
}
}