DirectoryInfo.GetFileSystemInfos()[0].LastAccessTime

解决方案 »

  1.   

    递归调用:
    void addFiles(string sPath){
    DirectoryInfo di=new DirectoryInfo(sPath);
    foreach(FileInfo fi in di.GetFiles){
    Console.Write(fi.LastAccessTime.ToString()+fi.Length.ToString());
    }
    foreach(DirecotryInfo dii in di.GetDirectorys){
    addFiles(dii.Name);
    }
    }
      

  2.   

    foreach(DirectoryInfo d in myPath)
    {
    // build up some literal controls, and buttons for the row of the table representing the directory
    Literal newColumn1 = new Literal();
    newColumn1.Text = "</td> <td>&nbsp;";
    Literal newColumn2 = new Literal();
    newColumn2.Text = "</td> <td>&nbsp;";
    Literal newColumn3 = new Literal();
    newColumn3.Text = "</td> <td>"; // display a folder icon
    Literal picColumn = new Literal();
    if(alternate%2 == 1) // alternate back-colour of rows
    picColumn.Text = "<TR><td><img src=pics/folder.gif></td><td>";
    else
    picColumn.Text = "<TR bgcolor='#e8e8e8'><td><img src=pics/folder.gif></td><td>";

    // this link changes the path to the directory being clicked
    LinkButton changePathBtn = new LinkButton();
    changePathBtn.Text = d.Name.ToString();
    changePathBtn.CommandArgument = d.Name.ToString();
    changePathBtn.Command += new CommandEventHandler(ChangePath); // this link deletes the directory, but it must be empty for the delete to be successful
    HyperLink deleteBtn = new HyperLink();
    deleteBtn.ImageUrl = "pics/delete_icon.gif";
    deleteBtn.NavigateUrl = "javascript:confirmDelete('delete.aspx?Type=Folder&Name=" + Server.UrlEncode(Session["Path"].ToString() + d.Name.ToString()) + "','" + d.Name.ToString()+ "');"; // use client-side confirm function for deleting

    Literal endRow = new Literal();
    endRow.Text = "</td></tr>"; // add the controls to the container in the webform
    this.FilesFolders.Controls.Add(picColumn);
    this.FilesFolders.Controls.Add(changePathBtn);
    this.FilesFolders.Controls.Add(newColumn1);
    this.FilesFolders.Controls.Add(newColumn2);
    this.FilesFolders.Controls.Add(newColumn3);
    this.FilesFolders.Controls.Add(deleteBtn);
    this.FilesFolders.Controls.Add(endRow); alternate++; // bump the int for back-colour alternation
    }