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. How to search for a file..

How to search for a file..

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestionlearning
22 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.
  • S Shah Satish

    Hi!!! I am just beginner in this field. I want to search for one specified file from the folder. as in I have one file called “WG_LL.txt “in my file.. n in each Webdoku section this file is contain inside loopo folder..ie File WG_LL.txt file is always inside of loopo folder but the location of loopo folder is different. For example… I created one dialogue box… and it contain my Webdoku section and path of the section.. Webdoku section Path of the section DEMO70E D:\Progsample\ProdV70E\ProdMast\ DEMO70D C:\project\webdoku\ SAMPLE D:\Prog. sample\ProdV70E\WebDoku\ DEMO80D E:\blabla\webdoku\ DEMO60E D:\Progsample\WebDoku\ WT1 \\rekafs\Projekte_USB\myfolder\9_WebDoku\ WT2 \\rekafs\Projekte_USB\myfolder\9_WebDoku\ If suppose, I select DEMO70E from my dialogue box then it should be search for “WG_LL.txt file” and here path of the file is …D:\Progsample\ProdV70E\WebDoku\loopo\WG.LL.txt. If suppose I select DEMO60E, then it should be search for file “WG_LL.txt” and path of the file is D:\Progsample\WebDoku\loopo\WG_LL.txt.. If suppose I select WT1, then it should be search for file “WG_LL.txt” and path of the file is \\rekafs\Projekte_USB\myfolder\9_WebDoku\WT1\loopo\WG_LL.txt In short, here I want to search for loopo folder coz WG_LL.txt” file will be contain in Loopo folder…Here I have some code in this file (WG_LL.txt) so I need this file. In my method…my section = selected Webdoku section (for example..DEMO70E) & Mypath =selected section path ( D:\Progsample\ProdV70E\ProdMast\) So how can I find that file with location of the path. Thank you very much… Shah Satish

    R Offline
    R Offline
    Rajesh R Subramanian
    wrote on last edited by
    #3

    Honestly, I didn't understand your query. But from the subject of your query, just check if

    PathFileExists()
    

    would be useful to you.

    Nobody can give you wiser advice than yourself. - Cicero

    S T 2 Replies Last reply
    0
    • R Rajesh R Subramanian

      Honestly, I didn't understand your query. But from the subject of your query, just check if

      PathFileExists()
      

      would be useful to you.

      Nobody can give you wiser advice than yourself. - Cicero

      S Offline
      S Offline
      Shah Satish
      wrote on last edited by
      #4

      Hi!! thanks fro your reply.. In short, I want to search file called "WG_LL.txt" from specified path.. see my code... if i select DEMO70E then specified path is D:\progrsample\prodv70E\prodmast... so i want to search that file in this directory..(D:\progrsample\prodv70E\prodmast...) Thank you.. Shah Satish

      R 1 Reply Last reply
      0
      • H Hamid Taebi

        If you want to search for a file you can use of FindFirstFile/FindNext` * * * WhiteSky * * * `

        S Offline
        S Offline
        Shah Satish
        wrote on last edited by
        #5

        Hi!! thanks fro your reply.. In short, I want to search file called "WG_LL.txt" from specified path.. see my code... if i select DEMO70E then specified path is D:\progrsample\prodv70E\prodmast... so i want to search that file in this directory..(D:\progrsample\prodv70E\prodmast...) Thank you.. Shah Satish

        H D 2 Replies Last reply
        0
        • S Shah Satish

          Hi!! thanks fro your reply.. In short, I want to search file called "WG_LL.txt" from specified path.. see my code... if i select DEMO70E then specified path is D:\progrsample\prodv70E\prodmast... so i want to search that file in this directory..(D:\progrsample\prodv70E\prodmast...) Thank you.. Shah Satish

          R Offline
          R Offline
          Rajesh R Subramanian
          wrote on last edited by
          #6

          Shah Satish wrote:

          In short, I want to search file called "WG_LL.txt" from specified path..

          Use the

          PathFileExists()
          

          function. Click here[^] to read about this function on msdn (with example)

          Nobody can give you wiser advice than yourself. - Cicero

          S 1 Reply Last reply
          0
          • S Shah Satish

            Hi!! thanks fro your reply.. In short, I want to search file called "WG_LL.txt" from specified path.. see my code... if i select DEMO70E then specified path is D:\progrsample\prodv70E\prodmast... so i want to search that file in this directory..(D:\progrsample\prodv70E\prodmast...) Thank you.. Shah Satish

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

            Well you can use of FindFirstFile did you try it I think its good for your purpose


            WhiteSky


            S 1 Reply Last reply
            0
            • R Rajesh R Subramanian

              Shah Satish wrote:

              In short, I want to search file called "WG_LL.txt" from specified path..

              Use the

              PathFileExists()
              

              function. Click here[^] to read about this function on msdn (with example)

              Nobody can give you wiser advice than yourself. - Cicero

              S Offline
              S Offline
              Shah Satish
              wrote on last edited by
              #8

              but in my case, I have to search a file from the path.. in your example...path is fixed..like " C:\\TEST\\file.txt" but in my case first of all ,it will search in test folder and then if it will found then return path of the file.. Shah Satish.

              R 1 Reply Last reply
              0
              • S Shah Satish

                but in my case, I have to search a file from the path.. in your example...path is fixed..like " C:\\TEST\\file.txt" but in my case first of all ,it will search in test folder and then if it will found then return path of the file.. Shah Satish.

                R Offline
                R Offline
                Rajesh R Subramanian
                wrote on last edited by
                #9

                In that case, check out WhiteSky's answer. That would be helpful for you.

                Nobody can give you wiser advice than yourself. - Cicero

                1 Reply Last reply
                0
                • R Rajesh R Subramanian

                  Honestly, I didn't understand your query. But from the subject of your query, just check if

                  PathFileExists()
                  

                  would be useful to you.

                  Nobody can give you wiser advice than yourself. - Cicero

                  T Offline
                  T Offline
                  ThatsAlok
                  wrote on last edited by
                  #10

                  brahmma wrote: PathFileExists() it's only determine that file exits on specified path or not!... you have RECURSIVE use CFileFind class

                  "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and you

                  R S 2 Replies Last reply
                  0
                  • T ThatsAlok

                    brahmma wrote: PathFileExists() it's only determine that file exits on specified path or not!... you have RECURSIVE use CFileFind class

                    "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and you

                    R Offline
                    R Offline
                    Rajesh R Subramanian
                    wrote on last edited by
                    #11

                    ThatsAlok wrote:

                    brahmma wrote: PathFileExists() it's only determine that file exits on specified path or not!... you have RECURSIVE use CFileFind class

                    Thanks, I know it. See this[^] post of that guy. He specified a file name and then a path too! That's the reason for me to have suggested him this particular function.

                    Nobody can give you wiser advice than yourself. - Cicero

                    S 1 Reply Last reply
                    0
                    • S Shah Satish

                      Hi!! thanks fro your reply.. In short, I want to search file called "WG_LL.txt" from specified path.. see my code... if i select DEMO70E then specified path is D:\progrsample\prodv70E\prodmast... so i want to search that file in this directory..(D:\progrsample\prodv70E\prodmast...) Thank you.. Shah Satish

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

                      Shah Satish wrote:

                      In short, I want to search file called "WG_LL.txt" from specified path..

                      So if you already know the file's path, why not use _access("D:\\progrsample\\prodv70E\\prodmast\\wg_ll.txt, 0)?


                      "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

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

                      S 1 Reply Last reply
                      0
                      • D David Crow

                        Shah Satish wrote:

                        In short, I want to search file called "WG_LL.txt" from specified path..

                        So if you already know the file's path, why not use _access("D:\\progrsample\\prodv70E\\prodmast\\wg_ll.txt, 0)?


                        "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

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

                        S Offline
                        S Offline
                        Shah Satish
                        wrote on last edited by
                        #13

                        Nop..This is the answer of my file path... Actually my path is "D:\progrsample\prodv70E\prodmast\.. and my file is contain in "D:\progrsample\ Prodv70E\webdocu\loopo\wg_ll.txt".. i just want to search folder from left side of my path.. but i dont know how to.. Thank you for your reply.. Shah Satish

                        D 1 Reply Last reply
                        0
                        • S Shah Satish

                          Nop..This is the answer of my file path... Actually my path is "D:\progrsample\prodv70E\prodmast\.. and my file is contain in "D:\progrsample\ Prodv70E\webdocu\loopo\wg_ll.txt".. i just want to search folder from left side of my path.. but i dont know how to.. Thank you for your reply.. Shah Satish

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

                          Your question is very incoherent.

                          Shah Satish wrote:

                          and my file is contain in "D:\progrsample\ Prodv70E\webdocu\loopo\wg_ll.txt"..

                          Since you already know the location of the file, what in the world are you searching for? :confused: If you simply want to search for a file, the answer has already been provided here.


                          "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

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

                          S 1 Reply Last reply
                          0
                          • D David Crow

                            Your question is very incoherent.

                            Shah Satish wrote:

                            and my file is contain in "D:\progrsample\ Prodv70E\webdocu\loopo\wg_ll.txt"..

                            Since you already know the location of the file, what in the world are you searching for? :confused: If you simply want to search for a file, the answer has already been provided here.


                            "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

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

                            S Offline
                            S Offline
                            Shah Satish
                            wrote on last edited by
                            #15

                            Hi!! I think my question is not clear..Ok looks once again.. I have dialogue box and it contain name of the section and path of the section..like.. Webdocu section Path of the section DEMO70E D:\Progsample\ProdV70E\ProdMast\ DEMO70D C:\project\webdoku\ SAMPLE D:\Prog. sample\ProdV70E\WebDoku\ DEMO80D E:\blabla\webdoku\ DEMO60E D:\Progsample\WebDoku\ WT1 \\rekafs\Projekte_USB\myfolder\9_WebDoku\ WT2 \\rekafs\Projekte_USB\myfolder\9_WebDoku\ Each section having own "wg_ll.txt" file.. for exapmple...If i will seclect DEMO70E then it will open WG_LL.txt file of that section (DEMO70E)... Can u tell me how i can find WG_LL.txt file??..I know its somewhere D:\Progsample\ProdV70E\ProdMast\ in this path but dont know exact location.I also want path of that file. So how can i find wg_LL.txt file with path for selected section..?? Shah Satish

                            D 1 Reply Last reply
                            0
                            • H Hamid Taebi

                              If you want to search for a file you can use of FindFirstFile/FindNext` * * * WhiteSky * * * `

                              S Offline
                              S Offline
                              Shah Satish
                              wrote on last edited by
                              #16

                              Hi!!! thanks for your reply..One more question please.. I have dialogue box and it contain name of the section and path of the section..like.. " Webdocu section " " Path of the section " DEMO70E D:\Progsample\ProdV70E\ProdMast\ DEMO70D C:\project\webdoku\ SAMPLE D:\Prog. sample\ProdV70E\WebDoku\ DEMO80D E:\blabla\webdoku\ DEMO60E D:\Progsample\WebDoku\ WT1 \\rekafs\Projekte_USB\myfolder\9_WebDoku\ WT2 \\rekafs\Projekte_USB\myfolder\9_WebDoku\ Each section having own "wg_ll.txt" file.. for exapmple...If i will seclect DEMO70E then it will open WG_LL.txt file of that section (DEMO70E)... Can u tell me how i can find WG_LL.txt file??..I know its somewhere D:\Progsample\ProdV70E\ProdMast\ in this path but dont know exact location.I also want path of that file. So how can i find wg_LL.txt file with path for selected section..?? Shah Satish

                              1 Reply Last reply
                              0
                              • H Hamid Taebi

                                Well you can use of FindFirstFile did you try it I think its good for your purpose


                                WhiteSky


                                S Offline
                                S Offline
                                Shah Satish
                                wrote on last edited by
                                #17

                                Hi!!! thanks for your reply..One more question please.. I have dialogue box and it contain name of the section and path of the section..like.. " Webdocu section " " Path of the section " DEMO70E D:\Progsample\ProdV70E\ProdMast\ DEMO70D C:\project\webdoku\ SAMPLE D:\Prog. sample\ProdV70E\WebDoku\ DEMO80D E:\blabla\webdoku\ DEMO60E D:\Progsample\WebDoku\ WT1 \\rekafs\Projekte_USB\myfolder\9_WebDoku\ WT2 \\rekafs\Projekte_USB\myfolder\9_WebDoku\ Each section having own "wg_ll.txt" file.. for exapmple...If i will seclect DEMO70E then it will open WG_LL.txt file of that section (DEMO70E)... Can u tell me how i can find WG_LL.txt file??..I know its somewhere D:\Progsample\ProdV70E\ProdMast\ in this path but dont know exact location.I also want path of that file. So how can i find wg_LL.txt file with path for selected section..?? Shah Satish

                                H 1 Reply Last reply
                                0
                                • R Rajesh R Subramanian

                                  ThatsAlok wrote:

                                  brahmma wrote: PathFileExists() it's only determine that file exits on specified path or not!... you have RECURSIVE use CFileFind class

                                  Thanks, I know it. See this[^] post of that guy. He specified a file name and then a path too! That's the reason for me to have suggested him this particular function.

                                  Nobody can give you wiser advice than yourself. - Cicero

                                  S Offline
                                  S Offline
                                  Shah Satish
                                  wrote on last edited by
                                  #18

                                  Hi!!! thanks for your reply..One more question please.. I have dialogue box and it contain name of the section and path of the section..like.. **" Webdocu section " " Path of the section "**DEMO70E D:\Progsample\ProdV70E\ProdMast\ DEMO70D C:\project\webdoku\ SAMPLE D:\Prog. sample\ProdV70E\WebDoku\ DEMO80D E:\blabla\webdoku\ DEMO60E D:\Progsample\WebDoku\ WT1 \\rekafs\Projekte_USB\myfolder\9_WebDoku\ WT2 \\rekafs\Projekte_USB\myfolder\9_WebDoku\ Each section having own "wg_ll.txt" file.. for exapmple...If i will seclect DEMO70E then it will open WG_LL.txt file of that section (DEMO70E)... Can u tell me how i can find WG_LL.txt file??..I know its somewhere D:\Progsample\ProdV70E\ProdMast\ in this path but dont know exact location.I also want path of that file. So how can i find wg_LL.txt file with path for selected section..?? Shah Satish shah Satish

                                  R 1 Reply Last reply
                                  0
                                  • T ThatsAlok

                                    brahmma wrote: PathFileExists() it's only determine that file exits on specified path or not!... you have RECURSIVE use CFileFind class

                                    "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and you

                                    S Offline
                                    S Offline
                                    Shah Satish
                                    wrote on last edited by
                                    #19

                                    Hi!!! thanks for your reply..One more question please.. I have dialogue box and it contain name of the section and path of the section..like.. " Webdocu section " " Path of the section " DEMO70E D:\Progsample\ProdV70E\ProdMast\ DEMO70D C:\project\webdoku\ SAMPLE D:\Prog. sample\ProdV70E\WebDoku\ DEMO80D E:\blabla\webdoku\ DEMO60E D:\Progsample\WebDoku\ WT1 \\rekafs\Projekte_USB\myfolder\9_WebDoku\ WT2 \\rekafs\Projekte_USB\myfolder\9_WebDoku\ Each section having own "wg_ll.txt" file.. for exapmple...If i will seclect DEMO70E then it will open WG_LL.txt file of that section (DEMO70E)... Can u tell me how i can find WG_LL.txt file??..I know its somewhere D:\Progsample\ProdV70E\ProdMast\ in this path but dont know exact location.I also want path of that file. So how can i find wg_LL.txt file with path for selected section..?? Shah Satish Shah Satish

                                    1 Reply Last reply
                                    0
                                    • S Shah Satish

                                      Hi!!! thanks for your reply..One more question please.. I have dialogue box and it contain name of the section and path of the section..like.. **" Webdocu section " " Path of the section "**DEMO70E D:\Progsample\ProdV70E\ProdMast\ DEMO70D C:\project\webdoku\ SAMPLE D:\Prog. sample\ProdV70E\WebDoku\ DEMO80D E:\blabla\webdoku\ DEMO60E D:\Progsample\WebDoku\ WT1 \\rekafs\Projekte_USB\myfolder\9_WebDoku\ WT2 \\rekafs\Projekte_USB\myfolder\9_WebDoku\ Each section having own "wg_ll.txt" file.. for exapmple...If i will seclect DEMO70E then it will open WG_LL.txt file of that section (DEMO70E)... Can u tell me how i can find WG_LL.txt file??..I know its somewhere D:\Progsample\ProdV70E\ProdMast\ in this path but dont know exact location.I also want path of that file. So how can i find wg_LL.txt file with path for selected section..?? Shah Satish shah Satish

                                      R Offline
                                      R Offline
                                      Rajesh R Subramanian
                                      wrote on last edited by
                                      #20

                                      I really don't understand your question man.

                                      Nobody can give you wiser advice than yourself. - Cicero

                                      1 Reply Last reply
                                      0
                                      • S Shah Satish

                                        Hi!!! thanks for your reply..One more question please.. I have dialogue box and it contain name of the section and path of the section..like.. " Webdocu section " " Path of the section " DEMO70E D:\Progsample\ProdV70E\ProdMast\ DEMO70D C:\project\webdoku\ SAMPLE D:\Prog. sample\ProdV70E\WebDoku\ DEMO80D E:\blabla\webdoku\ DEMO60E D:\Progsample\WebDoku\ WT1 \\rekafs\Projekte_USB\myfolder\9_WebDoku\ WT2 \\rekafs\Projekte_USB\myfolder\9_WebDoku\ Each section having own "wg_ll.txt" file.. for exapmple...If i will seclect DEMO70E then it will open WG_LL.txt file of that section (DEMO70E)... Can u tell me how i can find WG_LL.txt file??..I know its somewhere D:\Progsample\ProdV70E\ProdMast\ in this path but dont know exact location.I also want path of that file. So how can i find wg_LL.txt file with path for selected section..?? Shah Satish

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

                                        You can use of CFileDialogfor see a file is your purpose?


                                        WhiteSky


                                        1 Reply Last reply
                                        0
                                        • S Shah Satish

                                          Hi!! I think my question is not clear..Ok looks once again.. I have dialogue box and it contain name of the section and path of the section..like.. Webdocu section Path of the section DEMO70E D:\Progsample\ProdV70E\ProdMast\ DEMO70D C:\project\webdoku\ SAMPLE D:\Prog. sample\ProdV70E\WebDoku\ DEMO80D E:\blabla\webdoku\ DEMO60E D:\Progsample\WebDoku\ WT1 \\rekafs\Projekte_USB\myfolder\9_WebDoku\ WT2 \\rekafs\Projekte_USB\myfolder\9_WebDoku\ Each section having own "wg_ll.txt" file.. for exapmple...If i will seclect DEMO70E then it will open WG_LL.txt file of that section (DEMO70E)... Can u tell me how i can find WG_LL.txt file??..I know its somewhere D:\Progsample\ProdV70E\ProdMast\ in this path but dont know exact location.I also want path of that file. So how can i find wg_LL.txt file with path for selected section..?? Shah Satish

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

                                          I'm usually pretty good at deciphering, but you're still not making any sense. On more than one occasion, you stated things like, "I know the file ZZZ is in the XXX folder. I want to search that folder for file ZZZ." Why? If you already know that a file exists in a given folder, there's nothing to search, and no need to check if the file exists. Do you see why this is so confusing? You are asking for something that is completely unnecessary, or you are not asking for what you really want. In any case, we know nothing of things like "dialogue box and it contain name of the section and path of the section," "Webdocu section Path of the section," and "DEMO70E." Those are relevant only to you.


                                          "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

                                          "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