Hi,
I have tried to use InitialLocation of OpenItemDialog but unsuccessfully. To check not from my code I use FolderConnectionManager sample. InitialLocation folder exists, but it is not in the project folder connections. Maybe that is the reason?
Use the AlwaysUseInitialLocation property to force the OpenItemDialog to open the folder specified in the InitialLocation property. The behavior of the dialog is to open the last location opened using the current filter if you do not set this property to true.
Thanks
Uma
Hi Gintautas Kmieliauskas,
You are right initial location folder path need to be in the project folder connection.
So you have two options to try
Add the folder connection first before you use OpenItemDialog that with this code.
<SPAN class="keyword token">await</SPAN> QueuedTask<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Run</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">var</SPAN> folderToAdd <SPAN class="operator token">=</SPAN> ItemFactory<SPAN class="punctuation token">.</SPAN>Instance<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Create</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN>initial path<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> IProjectItem<SPAN class="punctuation token">;</SPAN> Project<SPAN class="punctuation token">.</SPAN>Current<SPAN class="punctuation token">.</SPAN><SPAN class="token function">AddItem</SPAN><SPAN class="punctuation token">(</SPAN>folderToAdd<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
or
Use the FolderBrowserDialog
Trade off is that UI does not look like ArcGIS pro theme.
And also quicker, if you just want your user to select a folder path.
Below is the sample code.
<SPAN class="keyword token">using</SPAN> <SPAN class="punctuation token">(</SPAN>FolderBrowserDialog tmpDestination <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">FolderBrowserDialog</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> tmpDestination<SPAN class="punctuation token">.</SPAN>Description <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Open your desired folder destination"</SPAN><SPAN class="punctuation token">;</SPAN> tmpDestination<SPAN class="punctuation token">.</SPAN>SelectedPath <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>your init folder path<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>tmpDestination<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ShowDialog</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">==</SPAN> DialogResult<SPAN class="punctuation token">.</SPAN>OK<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">string</SPAN> userSelectedFolderPath <SPAN class="operator token">=</SPAN> tmpDestination<SPAN class="punctuation token">.</SPAN>SelectedPath<SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
You shall need to replace the sample place holder [] with your variable accordingly.
Hi Than,
Thanks for help, but it doesn't work for me. I have tried your code with AddItem and saved in project folder connection but it doesn't work in both cases.
In my case I need to select rasters, lyrx'es and etc.
I have ArcGIS Pro 2.5 installed.
Thanks Uma.
It works know.
It would be nice in API reference to see near InitialLocation description note about AlwaysUseInitialLocation property behavior.
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.