piątek, 24 marca 2017

My class read binary files in listBox (Visual C++)

read_Files.h


#pragma once

using namespace System::IO;
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

ref class read_Files
{
private:
BinaryReader^ date_file;
ListBox^ lb;
String^ name_my_file;
FileStream^ my_file;
System::Single date;
public:
read_Files(String^ name_file,ListBox^ lbox);
void Read();
};

read_Files.cpp

#include "StdAfx.h"
#include "read_Files.h"

read_Files::read_Files(String^ name_file,ListBox^ lbox)
{
name_my_file=name_file;
lb=lbox;
}
void read_Files::Read()
{
 my_file=File::OpenRead(name_my_file);
 date_file=gcnew BinaryReader(my_file,System::Text::Encoding::Default);
 do
 {
date=date_file->ReadSingle();
lb->Items->Add(date.ToString());
 }while(date_file->PeekChar()!=-1);
 my_file->Close();
}

Brak komentarzy:

Prześlij komentarz