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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Checking to see if filename entered

Checking to see if filename entered

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
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.
  • N Offline
    N Offline
    NewHSKid
    wrote on last edited by
    #1

    Hi all, I am having trouble coding this and wanted to know how to check if a user enters a filename to open. Basically I want to check to make sure the file name is not all spaces and that it is not blank. I am not using CFileDialog right now, just have a editbox and a browse button that i got from a CP article. Does anyone have code out there that does this? Can someone lead me in the right direction? Thanks for all your help . Jimmy Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)

    T 1 Reply Last reply
    0
    • N NewHSKid

      Hi all, I am having trouble coding this and wanted to know how to check if a user enters a filename to open. Basically I want to check to make sure the file name is not all spaces and that it is not blank. I am not using CFileDialog right now, just have a editbox and a browse button that i got from a CP article. Does anyone have code out there that does this? Can someone lead me in the right direction? Thanks for all your help . Jimmy Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)

      T Offline
      T Offline
      Terry ONolley
      wrote on last edited by
      #2

      You can get at the string in the edit box with CString FileName; MyEditCOntrol.GetWindowText(&FileName); You can then perform all of the validation on FileName. To verify the edit box wasn't blank: if(!FileName.Getlength()) //handle error here - zero length filename To verify that no illegal filename characters were entered: CString InvalidFilenameChars = ""; // put all invalid filename chars in this string if(FileName.FindOneOf(InvalidFilenameChars) != -1) //handle error here - filename contains invalid character There may be a pre-built MFC way of handling all of this.........



      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