Unable to open openfileDialog in silverlight -
i want use openfiledialog upload file,but when write following code security exception fired "dialogs must user-initiated."
btn_click() { openfiledialog filedialog=new openfiledialog(); filedialog.multiselect = false; filedialog.filter = "all files|*.*"; bool? retval = filedialog.showdialog(); if (filedialog.showdialog()==false){ stream strm = filedialog.file.openread(); byte[] buffer = new byte[strm.length]; strm.read(buffer, 0, (int)strm.length); strm.dispose(); strm.close(); uploadfile file=new uploadfile(); file.filename = filedialog.file.name; file.file = buffer; po.fileuploadasync(file); }
as exception you're getting states open file dialog can activated user initiated action when application run in browser , restricted trust.
what trying achieve?
the simplest solution add button ui allows user control when process happens.
Comments
Post a Comment