Listing Files in a Directory for ASP.NET(Directory ListBox)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • renjucool
    New Member
    • Jun 2007
    • 15

    Listing Files in a Directory for ASP.NET(Directory ListBox)

    here is the code list all file in a folder-config it ur own,i list only .aspx files
    --------------------------------------------------------------------
    string dirPath = Server.MapPath( "");
    int dirPathLength = dirPath.Length;
    dirPathLength =dirPathLength+ 1;
    string[] files = System.IO.Direc tory.GetFiles(d irPath, "*.aspx");
    int fileArrLen = files.Length;
    int i = 0;
    Array Temp = Array.CreateIns tance(typeof(st ring), fileArrLen);
    foreach (string x in files)
    {
    string newX=x.Remove(0 , dirPathLength);
    Temp.SetValue(n ewX, i);
    i++;
    }
    lstAllFiles.Dat aSource = Temp;
    lstAllFiles.Dat aBind();


    With Regards
    www.renjur.co.n r
    RENJUR
    RENJUCOOL
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    Please post these in the articles section. Thanks.

    Comment

    Working...