SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2005
    Posts
    147
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Getting Names Of Files Within A Directory

    Hi

    First off let me explain what Im trying to achieve... I have a bunch of random images within a directory, what I would like to do is to get a list of all the images names that are in this directory so that I can insert the file names into a database.

    If I can get a list of the names into a datatable (or something else I can loop through) then I wont have trouble inserting them into a database, I just dont know how to get the file names within a directory.

    Please if someone can help I would appreciate it.
    Turn My Text - íspuǝıɹɟ ʞooqǝɔɐɟ ɹnoʎ ǝzɐɯɐ puɐ ǝsnɟuoɔ

    Computer Game Cheats & Codes

  2. #2
    Chopped Liver bronze trophy imaginekitty's Avatar
    Join Date
    Aug 2007
    Location
    Pennsyltucky
    Posts
    1,494
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Code:
    using System.IO;
    ...
    
            string path = Server.MapPath("~/img/");
            string[] files = Directory.GetFiles(path);
            FileInfo fi = new FileInfo(files[0]);


Bookmarks

Posting Permissions

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