// Binärdateien.cpp: Hauptprojektdatei.

#include "stdafx.h"

using namespace System;
using namespace System::IO;

int main(array<System::String ^> ^args)
{
   // in binäre Datei schreiben
   FileStream^ fs = gcnew FileStream("Durchschnittstemperaturen.txt", FileMode::OpenOrCreate);
   BinaryWriter^ bw = gcnew BinaryWriter(fs);

   bw->Write("Januar");
   bw->Write(0.4);
   bw->Write("Februar");
   bw->Write(1.6);
   bw->Write("März");
   bw->Write(4.7);
   bw->Write("April");
   bw->Write(8.3);

   bw->Close();


   // aus binärer Datei lesen
   fs = gcnew FileStream("Durchschnittstemperaturen.txt", FileMode::Open);
   BinaryReader^ br = gcnew BinaryReader(fs);

   String^ monatsname;
   double temperatur;

   while( br->PeekChar() != -1)
   {
      monatsname = br->ReadString();
      temperatur = br->ReadDouble();
      Console::WriteLine(" " + monatsname + ": " + temperatur);
   }

   br->Close();

   Console::ReadLine();
   return 0;
}
