You can't make that code work using a winform application. While using a winform application
you are compiling in a bit different language, C++/CLI. The syntax is quite the same of C++, but it can handle other features.
In a console app, every lines of code are executed one after another. This means, if you have 300 lines of code, that those will be executed but the compiler finds some kind of error.
In a Winform it is not necessarily true. If you want some code to be compiled, you have to fire some events.
Let's have this example. You have your app with a button that, if pressed, displays a popup with "Hello World". You will code just like that:
System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
MessageBox::Show("Hello World");
}
This code won't be "seen" by the compiler until button1
won't be clicked.
So, if you want your class to be used in your app, you need to:
- Convert in C++/CLI ( + find some tutorial about creation of winform apps :D )
- Figure out when and where you want your function to be called and code, for instance, a click event of a button( but you can choose between a lot of choices ).
Summarize this up, you will have something like that:
System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
/*Your converted Reading function */
MessageBox::Show("Error ! Could not open file: "+ FileName);
}