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. Folder and File traversing in C#

Folder and File traversing in C#

Scheduled Pinned Locked Moved C#
questioncsharphelp
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.
  • H Offline
    H Offline
    Harikrk
    wrote on last edited by
    #1

    i am doing a windows desktop application in C#. In this project when I select a folder i want to traverse through its subfolders and files to the leaf level. How can i do this in C#. I am selecting folder using FolderBrowserDialog. I am stuck after that.. how can i gets its fils and subfolders. I VB 6.0 and all we have files sytem and folder objects to travese. Here what we have to do? :( hope i will get a reply soon ...thanks ...hari

    V S 2 Replies Last reply
    0
    • H Harikrk

      i am doing a windows desktop application in C#. In this project when I select a folder i want to traverse through its subfolders and files to the leaf level. How can i do this in C#. I am selecting folder using FolderBrowserDialog. I am stuck after that.. how can i gets its fils and subfolders. I VB 6.0 and all we have files sytem and folder objects to travese. Here what we have to do? :( hope i will get a reply soon ...thanks ...hari

      V Offline
      V Offline
      vikashparida
      wrote on last edited by
      #2

      Use the DirectoryInfo class. DirectoryInfo di = new DirectoryInfo(path); FileSystemInfo[] fi = di.GetFileSystemInfos(); fi contains a list of all the folders and files in the directory represented by path. Now you can traverse through that list. Consult MSDN on DirectoryInfo class for further details

      ------------- The primary aim of AI is to make programming languages understand how frustrating it is to program them

      1 Reply Last reply
      0
      • H Harikrk

        i am doing a windows desktop application in C#. In this project when I select a folder i want to traverse through its subfolders and files to the leaf level. How can i do this in C#. I am selecting folder using FolderBrowserDialog. I am stuck after that.. how can i gets its fils and subfolders. I VB 6.0 and all we have files sytem and folder objects to travese. Here what we have to do? :( hope i will get a reply soon ...thanks ...hari

        S Offline
        S Offline
        Stefan Troschuetz
        wrote on last edited by
        #3

        The FolderBrowserDialog.SelectedPath property contains the Path selected by the user. Everything else you need can be found in the System.IO namespace in particular Directory, DirectoryInfo, File and FileInfo classes.


        "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

        www.troschuetz.de

        H 1 Reply Last reply
        0
        • S Stefan Troschuetz

          The FolderBrowserDialog.SelectedPath property contains the Path selected by the user. Everything else you need can be found in the System.IO namespace in particular Directory, DirectoryInfo, File and FileInfo classes.


          "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

          www.troschuetz.de

          H Offline
          H Offline
          Harikrk
          wrote on last edited by
          #4

          Thanks It worked for me :)

          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