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. How to recursively search directories

How to recursively search directories

Scheduled Pinned Locked Moved C#
csharptutorialquestiondata-structures
4 Posts 3 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.
  • I Offline
    I Offline
    iamnew2C
    wrote on last edited by
    #1

    Hi, I am new to C# .Net and have a question. I am tryng to recursively search directories. I have found a bunch of examples. Most are done using a console application. I want to accomplish this task via the web (Web Application). Does anyone have example on how to loop recursively through directories on your hard drive and return the info to an aspx page? I will be looking for zip files and will want to put the file info into an array so I can loop through & return the information. Thanks.

    L M 2 Replies Last reply
    0
    • I iamnew2C

      Hi, I am new to C# .Net and have a question. I am tryng to recursively search directories. I have found a bunch of examples. Most are done using a console application. I want to accomplish this task via the web (Web Application). Does anyone have example on how to loop recursively through directories on your hard drive and return the info to an aspx page? I will be looking for zip files and will want to put the file info into an array so I can loop through & return the information. Thanks.

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      iamnew2C# wrote:

      how to loop recursively through directories on your hard drive?

      iamnew2C# wrote:

      I have found a bunch of examples. Most are done using a console application.

      Same way from a Web App (ASP.NET).

      led mike

      1 Reply Last reply
      0
      • I iamnew2C

        Hi, I am new to C# .Net and have a question. I am tryng to recursively search directories. I have found a bunch of examples. Most are done using a console application. I want to accomplish this task via the web (Web Application). Does anyone have example on how to loop recursively through directories on your hard drive and return the info to an aspx page? I will be looking for zip files and will want to put the file info into an array so I can loop through & return the information. Thanks.

        M Offline
        M Offline
        mejojo
        wrote on last edited by
        #3

        string []files = System.IO.Directory.GetFiles(@"C:\SomeDir", "*.zip", System.IO.SearchOption.AllDirectories);

        I 1 Reply Last reply
        0
        • M mejojo

          string []files = System.IO.Directory.GetFiles(@"C:\SomeDir", "*.zip", System.IO.SearchOption.AllDirectories);

          I Offline
          I Offline
          iamnew2C
          wrote on last edited by
          #4

          Thank you for your response. I forgot to specify we have not upgraded to the 2.0 framework. System.IO.SearchOption opt = System.IO.SearchOption.AllDirectories; does not work. My first attempt(b4 the post) was DirectoryInfo di = new DirectoryInfo(@"C:\Temp"); foreach(DirectoryInfo file in di.GetDirectories()) { Response.Write("Looking at file \""+file.FullName+"\""+"
          "); } But it this does not go into subdirectiories. Help. Also, would you bind the result set to a data grid? What are the best option for displaying the result set to the web? Thanks in advance.

          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