Posted on: 5/14/2014 6:46:52 PM | Views : 306

Helo ,I want to open a saveFileDialog on button_click thats so simple! I've done it as well bt thorwing with an exception I've searched for solution bt helpless yet. Here is my code
protected void btnSve_Click(object sender, EventArgs e) {
try {
fileopen(); } catch (Exception ex) { } }
[STAThread] public void fileopen() {
SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.InitialDirectory = Convert.ToString(Environment.SpecialFolder.MyDocuments); saveFileDialog1.Filter = "All Files (*.*)|*.*"; saveFileDialog1.FilterIndex = 1;
saveFileDialog1.Show(); ----exception on this line }

Its throwing an exception like 'Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This ...

Go to the complete details ...