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 / C++ / MFC
  4. File extension validation

File extension validation

Scheduled Pinned Locked Moved C / C++ / MFC
question
8 Posts 5 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.
  • R Offline
    R Offline
    reddy harish
    wrote on last edited by
    #1

    Hi, iam developing a dailog based application in Wizard mode. i need to validate the file which the user is entering. so i need to validate the file extension.if the extension is wrong i need to pop a message saying wrong file. How can i validate the file extension. Regards Harish.

    H C _ D 4 Replies Last reply
    0
    • R reddy harish

      Hi, iam developing a dailog based application in Wizard mode. i need to validate the file which the user is entering. so i need to validate the file extension.if the extension is wrong i need to pop a message saying wrong file. How can i validate the file extension. Regards Harish.

      H Offline
      H Offline
      Hamid Taebi
      wrote on last edited by
      #2

      Did you used CFileDialog

      _**


      **_

      WhiteSky


      1 Reply Last reply
      0
      • R reddy harish

        Hi, iam developing a dailog based application in Wizard mode. i need to validate the file which the user is entering. so i need to validate the file extension.if the extension is wrong i need to pop a message saying wrong file. How can i validate the file extension. Regards Harish.

        C Offline
        C Offline
        Cedric Moonen
        wrote on last edited by
        #3

        Again ?? How many times did you already post your question ? What was wrong with the previous suggestions ? Did you look at CFileDialog ?


        Cédric Moonen Software developer
        Charting control [Updated - v1.1]

        R 1 Reply Last reply
        0
        • C Cedric Moonen

          Again ?? How many times did you already post your question ? What was wrong with the previous suggestions ? Did you look at CFileDialog ?


          Cédric Moonen Software developer
          Charting control [Updated - v1.1]

          R Offline
          R Offline
          reddy harish
          wrote on last edited by
          #4

          I have checked the earlier reply. As iam in learing curve i am not able to implement that exactly

          1 Reply Last reply
          0
          • R reddy harish

            Hi, iam developing a dailog based application in Wizard mode. i need to validate the file which the user is entering. so i need to validate the file extension.if the extension is wrong i need to pop a message saying wrong file. How can i validate the file extension. Regards Harish.

            _ Offline
            _ Offline
            _AnsHUMAN_
            wrote on last edited by
            #5

            Here's a code for you using CFileDialog

            CFileDialog *pDlg=new CFileDialog(true);
            if(pDlg->DoModal ()==IDOK)
            {
            CString str=pDlg->GetFileExt ();
            if(!str.CompareNoCase ("txt")) // Compare returns 0 if successful
            	AfxMessageBox ("Text File Selected");
            else
            	AfxMessageBox ("Select text files only");
            
            	}
            

            Hope this helps you...

            Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

            R 1 Reply Last reply
            0
            • _ _AnsHUMAN_

              Here's a code for you using CFileDialog

              CFileDialog *pDlg=new CFileDialog(true);
              if(pDlg->DoModal ()==IDOK)
              {
              CString str=pDlg->GetFileExt ();
              if(!str.CompareNoCase ("txt")) // Compare returns 0 if successful
              	AfxMessageBox ("Text File Selected");
              else
              	AfxMessageBox ("Select text files only");
              
              	}
              

              Hope this helps you...

              Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

              R Offline
              R Offline
              reddy harish
              wrote on last edited by
              #6

              Thanks for ur reply. but i have a small issue. iam using edit box in the dailog box.user enters the file in that edit box. how to validate that.

              _ 1 Reply Last reply
              0
              • R reddy harish

                Thanks for ur reply. but i have a small issue. iam using edit box in the dailog box.user enters the file in that edit box. how to validate that.

                _ Offline
                _ Offline
                _AnsHUMAN_
                wrote on last edited by
                #7

                reddy harish wrote:

                user enters the file in that edit box.

                you can use CString::Find() If you find the extension that you specified in the Find method you would get the index from where the extension starts. You can use this and validify the file extension.... You can also extract the file extension from the string and then use it for validation.(See as I did in my previous post) There could be some other possible ways also...

                Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

                1 Reply Last reply
                0
                • R reddy harish

                  Hi, iam developing a dailog based application in Wizard mode. i need to validate the file which the user is entering. so i need to validate the file extension.if the extension is wrong i need to pop a message saying wrong file. How can i validate the file extension. Regards Harish.

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #8

                  reddy harish wrote:

                  i need to validate the file which the user is entering.

                  Validate it for what?

                  reddy harish wrote:

                  if the extension is wrong...

                  Wrong in what context?


                  "Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.

                  "Judge not by the eye but by the heart." - Native American Proverb

                  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