Reputation: 1
I want to read a specific column/line from a file and save those to a variable. So far I was able to read the entire text. But I can't get my code to only read a specific line/column. Here is what I have:
private: System::Void button6_Click_1(System::Object^ sender, System::EventArgs^ e) {
Stream^ myStream;
OpenFileDialog^ openFileDialog1 = gcnew OpenFileDialog;
if (openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK)
{
if( (myStream = openFileDialog1->OpenFile()) != nullptr )
{
String^ strfilename = openFileDialog1->InitialDirectory + openFileDialog1->FileName;
String^ Readfile = File::ReadAllText(strfilename);
myStream->Close();
}
}
}
Upvotes: 0
Views: 2320
Reputation: 15375
You need to build your own parser.
I.E: Use StreamReader::ReadLine and than you may you String::Split to split all data into columns.
But you never told us what you define as a column...
Upvotes: 1