示例.txt:
127.0.0.1@user1;pass1
127.5.452.211@user2;pass2
27.33.5.31@user3;pass3
127.66.3.32@user4;pass4
我的程序需要从我的.txt文件中读取每一行,然后使用它提供的IP,用户名和密码。我只设法让它读取所有行,但我不知道如何从每行选择IP /用户/通行证以供以后使用。
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
//bool found = true;
//std::string IP;
//std::string Username;
//std::string Password;
//Stream^ myStream;
OpenFileDialog^ openFileDialog1 = gcnew OpenFileDialog;
openFileDialog1->InitialDirectory = "c:\\";
openFileDialog1->Title = "Game Account Database";
openFileDialog1->Filter = "CP files (*.cp)|*.cp|All files (*.*)|*.*|txt files (*.txt)|*.txt";
openFileDialog1->FilterIndex = 2;
openFileDialog1->Multiselect = true;
if ( openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK )
{
array<String^>^ lines = System::IO::File::ReadAllLines(openFileDialog1->FileName);
for each (String^ line in lines) {
System::Diagnostics::Debug::WriteLine("",line);
}
}
}
};