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. Searching randomly

Searching randomly

Scheduled Pinned Locked Moved C#
questioncsharpalgorithmshelp
9 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hello friends, how can I search for a file say 'filename.txt' randomly in the C: drive? The drive contains many folders and sub-directories, and thus I want to have a thorough search into all the folders and subdirectories present in the drive for the particular file. Please tell me how. NOTE: I dont know the names of the directories that are present in the drive. Hope to recieve help from you guys soon, Rajdeep.NET :rolleyes:

    F D T 3 Replies Last reply
    0
    • L Lost User

      Hello friends, how can I search for a file say 'filename.txt' randomly in the C: drive? The drive contains many folders and sub-directories, and thus I want to have a thorough search into all the folders and subdirectories present in the drive for the particular file. Please tell me how. NOTE: I dont know the names of the directories that are present in the drive. Hope to recieve help from you guys soon, Rajdeep.NET :rolleyes:

      F Offline
      F Offline
      fly904
      wrote on last edited by
      #2

      You obviously have an internet conenction because you're posting here, so I suggest you navigate to http://www.google.com/[^] and search 'c# file search'.

      My failometer is detecting vast quantities of FAIL! "Its SQL - hardly programming..." (Caslen)

      L 1 Reply Last reply
      0
      • F fly904

        You obviously have an internet conenction because you're posting here, so I suggest you navigate to http://www.google.com/[^] and search 'c# file search'.

        My failometer is detecting vast quantities of FAIL! "Its SQL - hardly programming..." (Caslen)

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        Can you show sample code please. Thank you very much.

        Luc Pattyn [Forum Guidelines] [My Articles]


        The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


        F J 2 Replies Last reply
        0
        • L Luc Pattyn

          Can you show sample code please. Thank you very much.

          Luc Pattyn [Forum Guidelines] [My Articles]


          The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


          F Offline
          F Offline
          fly904
          wrote on last edited by
          #4

          public Answer GoogleSearch(string question)
          {
          try
          {
          User.EngageBrain(); //Throws exception here.... please(or plz) help.
          User.NavigateToGoogle();
          return User.SearchForAnswer(question);
          }
          catch (StupidityException fail)
          {
          return (Answer)fail.Message;
          }
          }

          Hope that helps.

          My failometer is detecting vast quantities of FAIL! "Its SQL - hardly programming..." (Caslen)

          L 1 Reply Last reply
          0
          • F fly904

            public Answer GoogleSearch(string question)
            {
            try
            {
            User.EngageBrain(); //Throws exception here.... please(or plz) help.
            User.NavigateToGoogle();
            return User.SearchForAnswer(question);
            }
            catch (StupidityException fail)
            {
            return (Answer)fail.Message;
            }
            }

            Hope that helps.

            My failometer is detecting vast quantities of FAIL! "Its SQL - hardly programming..." (Caslen)

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            OK, have some vegemite :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: PS: got a compiler error (not all code paths return a value""), plz help.

            Luc Pattyn [Forum Guidelines] [My Articles]


            The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


            F 1 Reply Last reply
            0
            • L Luc Pattyn

              OK, have some vegemite :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: :vegemite: PS: got a compiler error (not all code paths return a value""), plz help.

              Luc Pattyn [Forum Guidelines] [My Articles]


              The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


              F Offline
              F Offline
              fly904
              wrote on last edited by
              #6

              Meh, no matter what people try, it always returns null in the end.

              My failometer is detecting vast quantities of FAIL! "Its SQL - hardly programming..." (Caslen)

              1 Reply Last reply
              0
              • L Lost User

                Hello friends, how can I search for a file say 'filename.txt' randomly in the C: drive? The drive contains many folders and sub-directories, and thus I want to have a thorough search into all the folders and subdirectories present in the drive for the particular file. Please tell me how. NOTE: I dont know the names of the directories that are present in the drive. Hope to recieve help from you guys soon, Rajdeep.NET :rolleyes:

                D Offline
                D Offline
                Dan Neely
                wrote on last edited by
                #7

                //assumes the file definitely exists. If it might not you'll need to add a counter and abort the search after X attempts, where X >> numValidPathChars^260 (260 = max normal path name)).
                fileNotFound = true;
                while (fileNotFound)
                {
                pathToTest = GetRandomPath();
                fileNotFound = (FileIsInDirectory(pathToTest,fileName);
                }

                It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains. -- Pride and Prejudice and Zombies

                1 Reply Last reply
                0
                • L Lost User

                  Hello friends, how can I search for a file say 'filename.txt' randomly in the C: drive? The drive contains many folders and sub-directories, and thus I want to have a thorough search into all the folders and subdirectories present in the drive for the particular file. Please tell me how. NOTE: I dont know the names of the directories that are present in the drive. Hope to recieve help from you guys soon, Rajdeep.NET :rolleyes:

                  T Offline
                  T Offline
                  terradtc
                  wrote on last edited by
                  #8

                  Be aware that most examples available through a search on google can and probably will result in an PathTooLongException, be sure to use the FindFirstFile function in kernel32.dll

                  1 Reply Last reply
                  0
                  • L Luc Pattyn

                    Can you show sample code please. Thank you very much.

                    Luc Pattyn [Forum Guidelines] [My Articles]


                    The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


                    J Offline
                    J Offline
                    jas0n23
                    wrote on last edited by
                    #9

                    hahaha

                    foreach( inch on Jason ) { Girlfriend.IsHappier(); }

                    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