Open File Dialog Box
Author: Panache
Creation Date: 9/15/2015 6:42 PM
profile picture

Panache

#1
I'd like to be able to select a text file to open in a Strategy with an Open File Dialog Box. I tried the code at https://msdn.microsoft.com/en-us/library/microsoft.win32.openfiledialog%28v=vs.110%29.aspx and got an error message that OpenFileDialog does not exist in Microsoft.Win32. After numerous modifications to the MSDN code and the addition of several using statements, I finally got it to compile. However, I get a runtime error that the current thread must be set to single thread apartment (STA) mode before OLE calls can be made.

Does anyone have some sample code for inserting an Open File Dialog Box in a Strategy (including the necessary references)?
profile picture

Eugene

#2
No, I don't think this is going to work even if you'd set the STAThread attribute. The best you can do is copy the path as string and paste it in an Input box.
profile picture

Panache

#3
Thanks Eugene. My work around was going to be to create a Strategy Parameter for which file I wanted to open, write the paths into the Strategy code and use the Strategy Parameter to pick the path.