Hi Guys,
I am using saveiteamDialog class(in pro 2.5) as shown in below code snippet
When I debugged, it seems locking the file, everytime using streamwriter it give me access denied error.
So I doubt something wrong and I tried with SaveFileDialog class from wpf build in, it is working well for me.
Just wanna check is there something wrong with file access by using saveitemdialog?
Any tips to clean those arcgis pro thread locking object?
SaveItemDialog tmpDestination <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">SaveItemDialog</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
Title <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Output file name"</SPAN><SPAN class="punctuation token">,</SPAN>
DefaultExt <SPAN class="operator token">=</SPAN> <SPAN class="string token">"txt"</SPAN><SPAN class="punctuation token">,</SPAN>
Filter <SPAN class="operator token">=</SPAN> <SPAN class="string token">"*.txt"</SPAN>
<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> <SPAN class="keyword token">true</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">try</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">string</SPAN> tmpPath <SPAN class="operator token">=</SPAN> tmpDestination<SPAN class="punctuation token">.</SPAN>FilePath<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">using</SPAN> <SPAN class="punctuation token">(</SPAN>StreamWriter sw <SPAN class="operator token">=</SPAN> File<SPAN class="punctuation token">.</SPAN><SPAN class="token function">CreateText</SPAN><SPAN class="punctuation token">(</SPAN>tmpPath<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="punctuation token">}</SPAN>
DestinationPath <SPAN class="operator token">=</SPAN> tmpPath<SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">catch</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="token class-name">Exception</SPAN> ex<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
MessageBox<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Show</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Unexpected error occurred:"</SPAN><SPAN class="operator token">+</SPAN>ex<SPAN class="punctuation token">.</SPAN>Message<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></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>