4
我正在第一次使用Managed C++ ...我使用Winform做了一個窗體,它有一個瀏覽文件目錄和用戶選擇的任何路徑的按鈕,路徑應該在文本框中可見。使用winforms和託管C++瀏覽文件對話框
我想知道如何在託管C++中創建文件瀏覽器對話框。
如果需要,附加表格的圖像。
我正在第一次使用Managed C++ ...我使用Winform做了一個窗體,它有一個瀏覽文件目錄和用戶選擇的任何路徑的按鈕,路徑應該在文本框中可見。使用winforms和託管C++瀏覽文件對話框
我想知道如何在託管C++中創建文件瀏覽器對話框。
如果需要,附加表格的圖像。
您正在尋找OpenFileDialog或SaveFileDialog。
void button1_Click(Object^ /*sender*/, System::EventArgs^ /*e*/)
{
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)
{
// Insert code to read the stream here.
myStream->Close();
}
}
}
謝謝你... :) – 2011-04-28 21:06:57