Share via


Windows Forms FileDialog

In my comments Kevin Westhead asks about the Windows Forms FileDialog. I was able to speak to grandpuba of Windows Forms, Mark Boulter who explained this as recommend a fix to the documentation:

FileDialog is a detail of the implementation of OpenFileDialog and SaveFileDialog. It exists purely to allow us to share code between these two classes. If we could make this class internal whilst making OFD and SFD public we would have done so.

 The documentation should explain this more clearly. The statement:

  "FileDialog is an abstract class, and cannot be created directly. Additionally, you cannot inherit from this class. To create a dialog box to select or save a file, use OpenFileDialog or SaveFileDialog."

Is close to nonsensical and should be replaced with something like:

"FileDialog is an abstract class that contains common behavior for the OpenFileDialog and SaveFileDialog classes. It is not intended to be used directly but contains common behavior for those two classes. You can neither create an instance of FileDialog nor inherit from it. To create a dialog box to select or save a file, use OpenFileDialog or SaveFileDialog."

Hope that helps

Comments

  • Anonymous
    February 23, 2004
    The comment has been removed
  • Anonymous
    February 23, 2004
    IMHO those two sentences are created automatically for each abstract and can't-use-as-a-base-class class. You have to treat them that way, don't think about what they're saying, think about them as markers for abstract classes, treat them as English equivalent of keywords :) Btw why can't you inherit from that class? Short of private abstract method there's nothing to stop you since OpenFileDialog and SaveFileDialog inherit from FileDialog...
  • Anonymous
    February 23, 2004
    I'm curious to know why this couldn't have been hidden as an implementation detail. Instead of inheriting from a public base class, aggregate the abstract internal class and have a way of accessing whatever interface you want from other classes, and have the Save/Open File dialogs either implement an interface that looks a lot like FileDialog, or inherit from an Impl-type class that knows how to get a FileDialog object.

    What causes this to not occur here?