Binary Writer
namespace Practica12problema2consola
{
class Program
{
static void Main(string[] args)
{
BinaryWriter bw = null;
try
{
bw=new BinaryWriter(new FileStream("c:\\PROM.txt",FileMode.Create,FileAccess.Write));
int N1, N2, N3, N4, N5, N6, N7, N8, N9, N10, N11, N12, N13, N14, N15, N16, N17, N18, N19, N20;
Console.WriteLine("Introduce el N1:");
N1=int.Parse(Console.ReadLine());
bw.Write(N1);
Console.WriteLine("Introduce el N2:");
N2 = int.Parse(Console.ReadLine());
bw.Write(N2);
Console.WriteLine("Introduce el N3:");
N3 = int.Parse(Console.ReadLine());
bw.Write(N3);
Console.WriteLine("Introduce el N4:");
N4 = int.Parse(Console.ReadLine());
bw.Write(N4);
Console.WriteLine("Introduce el N5:");
N5 = int.Parse(Console.ReadLine());
bw.Write(N5);
Console.WriteLine("Introduce el N6:");
N6 = int.Parse(Console.ReadLine());
bw.Write(N6);
Console.WriteLine("Introduce el N7:");
N7 = int.Parse(Console.ReadLine());
bw.Write(N7);
Console.WriteLine("Introduce el N8:");
N8 = int.Parse(Console.ReadLine());
bw.Write(N8);
Console.WriteLine("Introduce el N9:");
N9 = int.Parse(Console.ReadLine());
bw.Write(N9);
Console.WriteLine("Introduce el N10:");
N10 = int.Parse(Console.ReadLine());
bw.Write(N10);
Console.WriteLine("Introduce el N11:");
N11 = int.Parse(Console.ReadLine());
bw.Write(N11);
Console.WriteLine("Introduce el N12:");
N12 = int.Parse(Console.ReadLine());
bw.Write(N12);
Console.WriteLine("Introduce el N13:");
N13 = int.Parse(Console.ReadLine());
bw.Write(N13);
Console.WriteLine("Introduce el N14:");
N14 = int.Parse(Console.ReadLine());
bw.Write(N14);
Console.WriteLine("Introduce el N15:");
N15 = int.Parse(Console.ReadLine());
bw.Write(N15);
Console.WriteLine("Introduce el N16:");
N16 = int.Parse(Console.ReadLine());
bw.Write(N16);
Console.WriteLine("Introduce el N17:");
N17 = int.Parse(Console.ReadLine());
bw.Write(N17);
Console.WriteLine("Introduce el N18:");
N18 = int.Parse(Console.ReadLine());
bw.Write(N18);
Console.WriteLine("Introduce el N19:");
N19 = int.Parse(Console.ReadLine());
bw.Write(N19);
Console.WriteLine("Introduce el N20:");
N20 = int.Parse(Console.ReadLine());
bw.Write(N20);
}
catch(IOException e)
{
Console.WriteLine("Error:"+e.Message);
}
finally
{
if(bw !=null) bw.Close();
}
Console.ReadLine();
}
}
}
Binary Reader
namespace Practica12problema2consola
{
class Program
{
static void Main(string[] args)
{
BinaryWriter bw = null;
try
{
bw=new BinaryWriter(new FileStream("c:\\PROM.txt",FileMode.Create,FileAccess.Write));
int N1, N2, N3, N4, N5, N6, N7, N8, N9, N10, N11, N12, N13, N14, N15, N16, N17, N18, N19, N20;
Console.WriteLine("Introduce el N1:");
N1=int.Parse(Console.ReadLine());
bw.Write(N1);
Console.WriteLine("Introduce el N2:");
N2 = int.Parse(Console.ReadLine());
bw.Write(N2);
Console.WriteLine("Introduce el N3:");
N3 = int.Parse(Console.ReadLine());
bw.Write(N3);
Console.WriteLine("Introduce el N4:");
N4 = int.Parse(Console.ReadLine());
bw.Write(N4);
Console.WriteLine("Introduce el N5:");
N5 = int.Parse(Console.ReadLine());
bw.Write(N5);
Console.WriteLine("Introduce el N6:");
N6 = int.Parse(Console.ReadLine());
bw.Write(N6);
Console.WriteLine("Introduce el N7:");
N7 = int.Parse(Console.ReadLine());
bw.Write(N7);
Console.WriteLine("Introduce el N8:");
N8 = int.Parse(Console.ReadLine());
bw.Write(N8);
Console.WriteLine("Introduce el N9:");
N9 = int.Parse(Console.ReadLine());
bw.Write(N9);
Console.WriteLine("Introduce el N10:");
N10 = int.Parse(Console.ReadLine());
bw.Write(N10);
Console.WriteLine("Introduce el N11:");
N11 = int.Parse(Console.ReadLine());
bw.Write(N11);
Console.WriteLine("Introduce el N12:");
N12 = int.Parse(Console.ReadLine());
bw.Write(N12);
Console.WriteLine("Introduce el N13:");
N13 = int.Parse(Console.ReadLine());
bw.Write(N13);
Console.WriteLine("Introduce el N14:");
N14 = int.Parse(Console.ReadLine());
bw.Write(N14);
Console.WriteLine("Introduce el N15:");
N15 = int.Parse(Console.ReadLine());
bw.Write(N15);
Console.WriteLine("Introduce el N16:");
N16 = int.Parse(Console.ReadLine());
bw.Write(N16);
Console.WriteLine("Introduce el N17:");
N17 = int.Parse(Console.ReadLine());
bw.Write(N17);
Console.WriteLine("Introduce el N18:");
N18 = int.Parse(Console.ReadLine());
bw.Write(N18);
Console.WriteLine("Introduce el N19:");
N19 = int.Parse(Console.ReadLine());
bw.Write(N19);
Console.WriteLine("Introduce el N20:");
N20 = int.Parse(Console.ReadLine());
bw.Write(N20);
}
catch(IOException e)
{
Console.WriteLine("Error:"+e.Message);
}
finally
{
if(bw !=null) bw.Close();
}
Console.ReadLine();
}
}
}
