Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. SaveFileDialog filter

SaveFileDialog filter

Scheduled Pinned Locked Moved C#
comquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lsconyer
    wrote on last edited by
    #1

    Hello all. I'm trying to allow a user to save a text file and only a text file. My filter is "Text files (*txt)|*txt" This seems to be set up fine but when I save a file, I can save as .doc. This shouldn't happen, at least that's what I thought. Where am I going wrong?

    Lester http://www.lestersconyers.com

    D 1 Reply Last reply
    0
    • L lsconyer

      Hello all. I'm trying to allow a user to save a text file and only a text file. My filter is "Text files (*txt)|*txt" This seems to be set up fine but when I save a file, I can save as .doc. This shouldn't happen, at least that's what I thought. Where am I going wrong?

      Lester http://www.lestersconyers.com

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      You're making the assumption that the SaveAs dialog restricts the extension the user can use. Wrong. This only filter the filenames listed in the dialog box. You're code has to make sure the extension is correct, and fix it if it's not, after the user clicks OK and before you open the stream to start writing your data.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups