前台代码 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="list.aspx.cs" Inherits="zfyx_oa_Employee_list" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>无标题页</title> </head> <body> <form id="form1" runat="server"> <div> <asp:ListBox ID="LB_Postil" runat="server"></asp:ListBox> </div> </form> </body> </html>
后台代码 using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.IO;
public partial class zfyx_oa_Employee_list : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string FilePath = "E:\\111\\Abnormal"; if (!Directory.Exists(FilePath))// 保证不重复 { Directory.CreateDirectory(FilePath); } DirectoryInfo UnPostil = new DirectoryInfo(FilePath); FileInfo[] ArrUnPostil = UnPostil.GetFiles(); LB_Postil.Items.Clear(); foreach (FileInfo FileName in ArrUnPostil) { if(FileName.Length > 0) { LB_Postil.Items.Add(FileName.Name); } } } }
|