[Gtk-sharp-list] FileChooserDialog Problem

Darryl Pentz darryl.pentz at attix5.com
Fri Oct 7 08:36:56 EDT 2005


Is there a known problem with FileChooserDialog. I can't get it to work
though I'm following how it's used in MonoDevelop and in various Google
hits. The code I use is as follows:

            FileChooserDialog chooser = new FileChooserDialog("Select a
file", null, FileChooserAction.Open,
                                                              Stock.Open,
ResponseType.Ok, Stock.Cancel, ResponseType.Cancel);
            try {
                ResponseType choice = (ResponseType) chooser.Run();
                if (choice == ResponseType.Ok) {
                    DialogUtils.ShowInfoDialog((Gtk.Window) this.Toplevel,
"You selected " + chooser.Filename);
                }
            } catch (Exception e) {
                DialogUtils.ShowErrorDialog(null, e.Message);
            }
            finally {
                chooser.Destroy();
            }

It keeps throwing an exception which I determine to be:
Inner Exception: {} <-- the debugger doesn't indicate the type or even
provide an exception object to introspect

StackTrace
   at GLib.Marshaller.FilenamePtrToString(IntPtr ptr)
   at GLib.Marshaller.FilenamePtrToStringGFree(IntPtr ptr)
   at Gtk.FileChooserDialog.get_Filename()

I'm not sure if this is a known problem or if I'm doing something wrong.
Above, where I indicate 'null', I've also used the dialog that is the parent
to the button that initiates the opening of the FileChooserDialog, so that
isn't the problem.

Any help would be appreciated.

Should I just write my own dialog using FileChooserWidget? I guess I'll try
that regardless, in the meantime.

thanks,
Darryl Pentz



More information about the Gtk-sharp-list mailing list