<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic OpenFileDialog problem in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/openfiledialog-problem/m-p/8295865#M47329</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am creating an add in to batch insert Revit links to models.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first task is to add selected models path to listbox1 as following image:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 599px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/550950iA9E32588B31AA4F3/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;and following is my Code:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;  private void bt_AddModel_MouseClick(object sender, MouseEventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            if (openFileDialog1.ShowDialog()==DialogResult.OK)
            {
                string[] files = openFileDialog1.FileNames;
                foreach(string s in files)
                {
                    listBox1.Items.Add(s);
                }

            }
        }&lt;/PRE&gt;&lt;P&gt;But the problem is, after selecting all the files and click OK, the Winform add in close as well instead of add the files list into listbox.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone have experience in this, please help me.&lt;/P&gt;&lt;P&gt;Thank you so much for your help :).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cherry Truong&lt;/P&gt;</description>
    <pubDate>Thu, 27 Sep 2018 05:05:34 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-09-27T05:05:34Z</dc:date>
    <item>
      <title>OpenFileDialog problem</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/openfiledialog-problem/m-p/8295865#M47329</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am creating an add in to batch insert Revit links to models.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first task is to add selected models path to listbox1 as following image:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 599px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/550950iA9E32588B31AA4F3/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;and following is my Code:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;  private void bt_AddModel_MouseClick(object sender, MouseEventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            if (openFileDialog1.ShowDialog()==DialogResult.OK)
            {
                string[] files = openFileDialog1.FileNames;
                foreach(string s in files)
                {
                    listBox1.Items.Add(s);
                }

            }
        }&lt;/PRE&gt;&lt;P&gt;But the problem is, after selecting all the files and click OK, the Winform add in close as well instead of add the files list into listbox.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone have experience in this, please help me.&lt;/P&gt;&lt;P&gt;Thank you so much for your help :).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cherry Truong&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2018 05:05:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/openfiledialog-problem/m-p/8295865#M47329</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-09-27T05:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: OpenFileDialog problem</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/openfiledialog-problem/m-p/8296192#M47330</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Inside your Windows form, store the selected files in a list that is accessible via a public member function, e.g., SelectedFiles.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Then, access those files and process them after the form has been confirmed and closed:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;  class Command : IExternalCommand
  {
    Result Execute(...)
    {
      FileSelectionForm form = new FileSelectionForm();
      if (form.ShowDialog()==DialogResult.OK)
      {
        string[] files = form.SelectedFiles;
        foreach(string s in files)
        {
          process file
        }
      }
    }
  }&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Lots of samples by The Building Coder demonstrate how to display a Windows form prompting a user for input in an external command and process the results afterwards:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://www.google.com/search?q=ShowDialog&amp;amp;as_sitesearch=thebuildingcoder.typepad.com" target="_blank"&gt;https://www.google.com/search?q=ShowDialog&amp;amp;as_sitesearch=thebuildingcoder.typepad.com&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Jeremy&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2018 08:47:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/openfiledialog-problem/m-p/8296192#M47330</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2018-09-27T08:47:28Z</dc:date>
    </item>
    <item>
      <title>Re: OpenFileDialog problem</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/openfiledialog-problem/m-p/8301844#M47331</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Dear Jeremy,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you so much for your help. I can fix the problem now :). and finished my add in to batch upgrade families to current version of Revit.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Best Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Ninh Truong&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 29 Sep 2018 15:30:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/openfiledialog-problem/m-p/8301844#M47331</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-09-29T15:30:32Z</dc:date>
    </item>
  </channel>
</rss>

