Results 1 to 4 of 4

Thread: List files in a directory

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2003
    Posts
    830

    List files in a directory

    For some reason..I thought this would be easy, but it is giving me a fit. I want to display a list of files in a listbox (or whatever is appropriate) from a directory. I just can't seem to work it out. Help!

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    Re: List files in a directory

    Quote Originally Posted by birthjay
    For some reason..I thought this would be easy, but it is giving me a fit. I want to display a list of files in a listbox (or whatever is appropriate) from a directory. I just can't seem to work it out. Help!
    MSDN
    System.IO namespace
    DirectoryInfo
    FileInfo

  3. #3
    Lively Member
    Join Date
    Mar 2003
    Location
    US
    Posts
    68

    Re: List files in a directory

    should be correct syntax ;

    for each (string s in System.IO.Directory.GetFiles(@"folderPath")
    {
    ListBox1.Items.Add(s);
    }

  4. #4
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196

    Re: List files in a directory

    I think the filename is returned from the ToString() method so just to be annoying
    Code:
    ListBox1.Items.AddRange(Directory.GetFiles("path"));

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width