我通过浏览文件夹并在单击浏览按钮后选择文件来获取文件的完整路径。
但我只想通过浏览来获取文件夹的路径。
我为文件路径做了以下
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();
}