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. Need help Urgent

Need help Urgent

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
8 Posts 6 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 Dialog based application. In that application user has to add some files to perfrom the next operation, so i need to validate the file path,file name,for further operation. how can i check that user has entered the correct path,file name

    C C H T Z 5 Replies Last reply
    0
    • R reddy harish

      Hi Iam developing a Dialog based application. In that application user has to add some files to perfrom the next operation, so i need to validate the file path,file name,for further operation. how can i check that user has entered the correct path,file name

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

      reddy harish wrote:

      how can i check that user has entered the correct path,file name

      It depends of what you mean by that exactly. If you simply want to check if the file exist, you can simply try to open is (with fopen for example) and if the function succeed, then the file exists. Supply the absolute path so that you can check the path and the file name.


      Cédric Moonen Software developer
      Charting control

      R 1 Reply Last reply
      0
      • R reddy harish

        Hi Iam developing a Dialog based application. In that application user has to add some files to perfrom the next operation, so i need to validate the file path,file name,for further operation. how can i check that user has entered the correct path,file name

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        Easiest way - get them to select files with the file dialog and set the style so the filename entered must exist.

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

        1 Reply Last reply
        0
        • R reddy harish

          Hi Iam developing a Dialog based application. In that application user has to add some files to perfrom the next operation, so i need to validate the file path,file name,for further operation. how can i check that user has entered the correct path,file name

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

          See Cedric Moonen answer.... and see SetCurrentDirectory(...) and see return value.Is your purpose

          _**


          **_

          WhiteSky


          1 Reply Last reply
          0
          • C Cedric Moonen

            reddy harish wrote:

            how can i check that user has entered the correct path,file name

            It depends of what you mean by that exactly. If you simply want to check if the file exist, you can simply try to open is (with fopen for example) and if the function succeed, then the file exists. Supply the absolute path so that you can check the path and the file name.


            Cédric Moonen Software developer
            Charting control

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

            Thnks for ur reply. but If the user is entering the wrong file path or file name and he is trying to perform the next operation,how can we prevent him from that.so that we have to write the code to give him messeage or to stop him. Ex:when we are entering the wrong file name or path in the "RUN" command,it shows us a warning or message saying that is not exist. Like that can we perform the operation

            C 1 Reply Last reply
            0
            • R reddy harish

              Thnks for ur reply. but If the user is entering the wrong file path or file name and he is trying to perform the next operation,how can we prevent him from that.so that we have to write the code to give him messeage or to stop him. Ex:when we are entering the wrong file name or path in the "RUN" command,it shows us a warning or message saying that is not exist. Like that can we perform the operation

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

              Uuuhh :confused: ?? Did you read my post :~ ? If you try to open a file that doesn't exist in read mode, fopen will return an error. So in that case you know that the file is wrong and you can display a message and not continue to the next step. Anyway, the solution of Christian is better (and you provide also an elegant way to choose the file for the user).


              Cédric Moonen Software developer
              Charting control

              1 Reply Last reply
              0
              • R reddy harish

                Hi Iam developing a Dialog based application. In that application user has to add some files to perfrom the next operation, so i need to validate the file path,file name,for further operation. how can i check that user has entered the correct path,file name

                T Offline
                T Offline
                toxcct
                wrote on last edited by
                #7

                ::PathFileExists()[^]


                TOXCCT >>> GEII power

                [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

                1 Reply Last reply
                0
                • R reddy harish

                  Hi Iam developing a Dialog based application. In that application user has to add some files to perfrom the next operation, so i need to validate the file path,file name,for further operation. how can i check that user has entered the correct path,file name

                  Z Offline
                  Z Offline
                  Zac Howland
                  wrote on last edited by
                  #8

                  Christian's solution will work for the most part. I'd just add that after you select a file, use CFile::GetStatus to determine if it exists or not. The method will return TRUE if it succeeds, and FALSE if the file/directory doesn't exist.

                  If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac

                  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