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#
  4. find files

find files

Scheduled Pinned Locked Moved C#
question
28 Posts 9 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.
  • M michaelgr1

    for example; 061_pmr_c0_txhb_cut_rxhb_to_smx.vl.GIF

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #19

    Why you didn't use my code ? (The first Comment ?) :confused: No offense , it's just a kind of discussion ... :rose: thank you ...

    I know nothing , I know nothing ...

    M 1 Reply Last reply
    0
    • R Rob Philpott

      Stark DaFixzer wrote:

      SearchOption.AllDirectories

      Not seen that before and have always written a recursive procedure for this sort of thing. Does this work?

      Regards, Rob Philpott.

      M Offline
      M Offline
      Mike Devenney
      wrote on last edited by
      #20

      Yep. I use it in a homebaked app to catalog my picture collection.

      Mike Devenney

      1 Reply Last reply
      0
      • L Lost User

        Why you didn't use my code ? (The first Comment ?) :confused: No offense , it's just a kind of discussion ... :rose: thank you ...

        I know nothing , I know nothing ...

        M Offline
        M Offline
        michaelgr1
        wrote on last edited by
        #21

        Hello, I tried many ways to do it (as you wrote and another ways) but in all of them it doesn't always find the file i need. For example if the starting path is the immediate folder that contains the file it works fine and finds the file, but when the starting patch is a higher (maybe 2-3 folder upper) it doesn't find this file (i write exactly the same name). It seems it doesn't enough time to the program to collect all the files names inside the folder. I did a little delay but it didn't help. This is my code: foreach (string d in Directory.GetDirectories(Start_dir)) { if (!d.Contains("Shared Documents")) { System.Threading.Thread.Sleep(200); foreach (string f in Directory.GetFiles(d)) { //MessageBox.Show(f); if (f.Contains(search)) { Process.Start(f); review_file_found = true; return; } } dirsearch(d, search); } }

        M 1 Reply Last reply
        0
        • M michaelgr1

          Hello, I tried many ways to do it (as you wrote and another ways) but in all of them it doesn't always find the file i need. For example if the starting path is the immediate folder that contains the file it works fine and finds the file, but when the starting patch is a higher (maybe 2-3 folder upper) it doesn't find this file (i write exactly the same name). It seems it doesn't enough time to the program to collect all the files names inside the folder. I did a little delay but it didn't help. This is my code: foreach (string d in Directory.GetDirectories(Start_dir)) { if (!d.Contains("Shared Documents")) { System.Threading.Thread.Sleep(200); foreach (string f in Directory.GetFiles(d)) { //MessageBox.Show(f); if (f.Contains(search)) { Process.Start(f); review_file_found = true; return; } } dirsearch(d, search); } }

          M Offline
          M Offline
          michaelgr1
          wrote on last edited by
          #22

          Or it even seems as it doesn't have enough memory to do this search. Because files (in directories) that are located in the "beginning of the list" it finds (and opens), But files that are located a little "deeper" in the list he can't file and even the application get stucked in such situations

          W 2 Replies Last reply
          0
          • M michaelgr1

            Or it even seems as it doesn't have enough memory to do this search. Because files (in directories) that are located in the "beginning of the list" it finds (and opens), But files that are located a little "deeper" in the list he can't file and even the application get stucked in such situations

            W Offline
            W Offline
            WinSolution
            wrote on last edited by
            #23

            If there is way so i can send you the project just replace the path, recompile, run the project. put expression and click on the button. list will be displayed. It is working on my PC.

            M 1 Reply Last reply
            0
            • W WinSolution

              If there is way so i can send you the project just replace the path, recompile, run the project. put expression and click on the button. list will be displayed. It is working on my PC.

              M Offline
              M Offline
              michaelgr1
              wrote on last edited by
              #24

              OK, You can send me it to michgr@nana.co.il thanks very much

              W 1 Reply Last reply
              0
              • M michaelgr1

                Or it even seems as it doesn't have enough memory to do this search. Because files (in directories) that are located in the "beginning of the list" it finds (and opens), But files that are located a little "deeper" in the list he can't file and even the application get stucked in such situations

                W Offline
                W Offline
                WinSolution
                wrote on last edited by
                #25

                here is it download it http://rapidshare.com/files/238592801/WindowsApplication1.rar.html[^]

                1 Reply Last reply
                0
                • M michaelgr1

                  OK, You can send me it to michgr@nana.co.il thanks very much

                  W Offline
                  W Offline
                  WinSolution
                  wrote on last edited by
                  #26

                  i have sent a mail also to you i was in hurry so without subject

                  M 2 Replies Last reply
                  0
                  • W WinSolution

                    i have sent a mail also to you i was in hurry so without subject

                    M Offline
                    M Offline
                    michaelgr1
                    wrote on last edited by
                    #27

                    OK thanks, I will try it and let you know

                    1 Reply Last reply
                    0
                    • W WinSolution

                      i have sent a mail also to you i was in hurry so without subject

                      M Offline
                      M Offline
                      michaelgr1
                      wrote on last edited by
                      #28

                      Hi, The code you sent me works fine, but very very slow. My code works much faster: foreach (string d in Directory.GetDirectories(Start_dir)) { if (!d.Contains("Shared Documents") && !d.Contains("Anna") && !d.Contains("CE Group") && !d.Contains("DEF") && !d.Contains("DtReport") && !d.Contains("images") && !d.Contains("Lists") && !d.Contains("MMGBD") && !d.Contains("Site") && !d.Contains("SP Requests") && !d.Contains("STAM") && !d.Contains("Training") && !d.Contains("uptest") && !d.Contains("X5") && !d.Contains("X8") && !d.Contains("Form") && !d.Contains("Yonah")) { //System.Threading.Thread.Sleep(200); foreach (string f in Directory.GetFiles(d)) { //System.Threading.Thread.Sleep(200); //MessageBox.Show(f); m=f.Replace("\\"+"\\moss.ger.ith.intel.com\\sites\\MPGBD-03\\HAL\\PD\\",""); //MessageBox.Show(m); if (m.Contains(search1)) { MessageBox.Show("found"); //System.Net.WebClient client = new WebClient(); //client.UseDefaultCredentials = true; //client.DownloadFile(f, @"c:\\123.gif"); //Process.Start(@"c:\\123.gif"); //System.Threading.Thread.Sleep(500); //Process.Start(f); review_file_found = true; return; } } dirsearch(d, search1); } } The problem is that with this code (with the messagebox.show("found") it finds the file (the message appears). But when i usethe process.start and try to open the file or even to download it it seems as it doesn't see the file at all (some files it sees and some not). It seems as it doesn't enter the if condition at all (even don't do the - review_file_found=true because outside this method i check the status of the bool and show a messagebox says the file not

                      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