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 Read folder contents [modified]

how to Read folder contents [modified]

Scheduled Pinned Locked Moved C#
csharpsalesxmltutorial
5 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.
  • S Offline
    S Offline
    salmonraju
    wrote on last edited by
    #1

    Hi, I am creating a windows application,that contains a folder,with 5 files. how to programaticlly get the names of all the files in that folder(getting names of all the contents of that folder) Say folder name is "MyXMLFolder" .It contains elemnts as -Customer.xml -Employee.Xml -Bank.xml I want c# coding to get all the names of the files in "MyXMLFolder" folder -- modified at 2:13 Monday 13th August, 2007

    M T 2 Replies Last reply
    0
    • S salmonraju

      Hi, I am creating a windows application,that contains a folder,with 5 files. how to programaticlly get the names of all the files in that folder(getting names of all the contents of that folder) Say folder name is "MyXMLFolder" .It contains elemnts as -Customer.xml -Employee.Xml -Bank.xml I want c# coding to get all the names of the files in "MyXMLFolder" folder -- modified at 2:13 Monday 13th August, 2007

      M Offline
      M Offline
      Michael Sync
      wrote on last edited by
      #2

      DirectoryInfo dir = new DirectoryInfo(@"F:\MyFolder"); FileInfo[] files = dir.GetFiles("*.*"); Foreach(FileInfo f in files ) { Console.WriteLine("Name is : {0}", f.Name); Console.WriteLine("Length of the file is : {0}", f.Length); Console.WriteLine("Creation time is : {0}", f.CreationTime); Console.WriteLine("Attributes of the file are : {0}", f.Attributes.ToString()); } Ref: Working with Files in C#[^] File Information using C#[^] Hope it helps.

      Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

      S 1 Reply Last reply
      0
      • S salmonraju

        Hi, I am creating a windows application,that contains a folder,with 5 files. how to programaticlly get the names of all the files in that folder(getting names of all the contents of that folder) Say folder name is "MyXMLFolder" .It contains elemnts as -Customer.xml -Employee.Xml -Bank.xml I want c# coding to get all the names of the files in "MyXMLFolder" folder -- modified at 2:13 Monday 13th August, 2007

        T Offline
        T Offline
        tker
        wrote on last edited by
        #3

        Hi, You need to use the System.IO namespace. The following code will get you all files in a folder as strings in a string array, including the folder path: string[] files = Directory.GetFiles(@"c:\MyXMLFolder"); Everything you will need to work with files can be found in System.IO. Regards, Toby

        S 1 Reply Last reply
        0
        • T tker

          Hi, You need to use the System.IO namespace. The following code will get you all files in a folder as strings in a string array, including the folder path: string[] files = Directory.GetFiles(@"c:\MyXMLFolder"); Everything you will need to work with files can be found in System.IO. Regards, Toby

          S Offline
          S Offline
          salmonraju
          wrote on last edited by
          #4

          Thank you ,It is working

          1 Reply Last reply
          0
          • M Michael Sync

            DirectoryInfo dir = new DirectoryInfo(@"F:\MyFolder"); FileInfo[] files = dir.GetFiles("*.*"); Foreach(FileInfo f in files ) { Console.WriteLine("Name is : {0}", f.Name); Console.WriteLine("Length of the file is : {0}", f.Length); Console.WriteLine("Creation time is : {0}", f.CreationTime); Console.WriteLine("Attributes of the file are : {0}", f.Attributes.ToString()); } Ref: Working with Files in C#[^] File Information using C#[^] Hope it helps.

            Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

            S Offline
            S Offline
            salmonraju
            wrote on last edited by
            #5

            Thank you, for detailed description, working

            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