使用 winforms 和托管 C++ 浏览文件对话框

发布于 2024-11-03 13:55:05 字数 201 浏览 2 评论 0原文

我第一次使用托管 C++...我使用 Winform 制作了一个表单,其中有一个按钮可以浏览文件目录,无论用户选择哪个路径,该路径都应该在文本框中可见。

我想知道如何在托管 C++ 中创建文件浏览器对话框。

如果需要,请附上表格的图像。 在此处输入图像描述

I am working on Managed C++ for the first time... I have made a form using Winform which has a button to browse through directories for file and whichever path the user selects, the path should be visible on the text box.

I wanted to know how to create the file browser dialog box in Managed C++.

Attaching the image of the form if required.
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蝶舞 2024-11-10 13:55:05

您正在寻找 OpenFileDialogSaveFileDialog

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();
             }
          }
       }

You're looking for OpenFileDialog or 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();
             }
          }
       }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文