SaveFileDialog Box Filetype Filter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MZimmerman6
    New Member
    • May 2010
    • 8

    #1

    SaveFileDialog Box Filetype Filter

    I have a pretty quick question. When adding a saveFileDialog box, how can I filter it so it only searches for certain file types. Namely XML. If found something online that looked like:

    saveFileDialog1 .Filter = "DAT31-8 Files (*.N31)|*.xml|A ll Files (*.*)|*.*" ;

    but editting that does not really help me any

    I imagine it is a fairly easy fix, but can not find any documentation on it. Thanks for your help in advance.
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    The filter string isn't all that intuitive.
    Basically it's making pairs by the | divider
    Consider this filter string: "All Files (*.*)|*.*"
    The first part "All Files (*.*)" is the displayed portion in the filter selection of the dialog box, while the second part "*.*" is the actual filter supplied.
    You need two parts for each entry you want in the filter selection.

    In your case, for 3 entries you might want:
    [code=C#]

    saveFileDialog1 .Filter = "DAT31-8 Files (*.N31)|*.N31|X ML Files (*.XML)|*.xml|A ll Files (*.*)|*.*" ;

    [/code]

    Comment

    Working...