您好,并提前感谢您。 我想要做的是显示目录的所有文件。 目录的路径包含在代码中。
我想要做的是询问用户目录,然后使用该目录的路径而不是:("*.*")
C#CODE
protected void ListFiles(object sender, EventArgs e)
{
DirectoryInfo dirInfo = new DirectoryInfo(Server.MapPath("~/"));
System.IO.FileInfo[] fileNames = dirInfo.GetFiles("*.*");
foreach (System.IO.FileInfo fi in fileNames)
{
listbox1.Items.Add(string.Format("{0} | {1} | {2} KB", fi.Name, fi.LastAccessTime, fi.Length));
}
}
ASP代码
<asp:ListBox ID="listbox1" runat="server" OnLoad="ListFiles"Height="500" Width="600" Font-Bold="true"></asp:ListBox>
感谢您的帮助。
答案 0 :(得分:0)
假设您希望用户从try this或this answer选择服务器上的this目录。
如果您希望用户在其计算机上选择目录,请使用.NET框架的HTMLInputFile类。