点击浏览按钮后,浏览文件夹并选择文件,即可获得完整的文件路径。
但我希望通过浏览路径到 。
我为文件路径
执行了以下操作 Stream^ myStream;
OpenFileDialog^ openFileDialog1 = gcnew OpenFileDialog;
openFileDialog1->InitialDirectory = "c:\\";
//openFileDialog1->Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
openFileDialog1->FilterIndex = 2;
openFileDialog1->RestoreDirectory = true;
if ( openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK )
{
if ( (myStream = openFileDialog1->OpenFile()) != nullptr )
{
String^ p1 = openFileDialog1->FileName;
MessageBox ::Show (p1);
myStream->Close();
}