open (print)a text file to the screen

A

Allen

Can anybody tell me how to open (print)a text file to the screen. For
example, to click a botton and the file will be shown in the screen. Using
something like the code below.(the code below is not good, but I want to
give you an idea)

private: System::Void ShwCrdBtn_Click(System::Object^ sender,
System::EventArgs^ e)

{
FileInfo^ fi = gcnew FileInfo("C:\\MyFile.txt");
fi->OpenRead();

}
 
F

Family Tree Mike

Can anybody tell me how to open (print)a text file to the screen. For
example, to click a botton and the file will be shown in the screen. Using
something like the code below.(the code below is not good, but I want to
give you an idea)

private: System::Void ShwCrdBtn_Click(System::Object^ sender,
System::EventArgs^ e)

{
FileInfo^ fi = gcnew FileInfo("C:\\MyFile.txt");
fi->OpenRead();

}

You'll need to do the translation to C++, but in C#, I think you want:

string txt = File.ReadAllText(@"c:\myfile.txt");
MessageBox.Show(txt);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top