触摸屏租赁
Touch screen rental
广告机租赁
Advertising rental
机器人租赁
Robot leasing
 当前位置:首页 > > .net得到本机指定目录下的所有文件

前台代码
<%@ 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);
        }
        }
    }
}

来源:展洋科技 www.35544216.com


工作室地址:重庆石桥铺电脑城B座 | 微信:z35544216 | 网址:www.35544216.com