午夜视频在线网站,日韩视频精品在线,中文字幕精品一区二区三区在线,在线播放精品,1024你懂我懂的旧版人,欧美日韩一级黄色片,一区二区三区在线观看视频

分享

文件下載相關(guān)知識(shí)

 實(shí)力決定地位 2010-05-10
這是一個(gè)獲取文件夾文件的信息
 public static List<Filters> GetFileList(string path1)
       {
           DirectoryInfo d = new DirectoryInfo(path1);
           FileInfo [] fl= d.GetFiles();
           List<Filters> lis = new List<Filters>();
           foreach(FileInfo f in fl  )
           {
               Filters fi = new Filters();
               fi.Extends = f.Extension;
               fi.Fullname = f.FullName;
               fi.Length = f.Length;
               fi.Name = f.Name;
               lis.Add(fi);
              
           }
           return lis;
       }
下面是文件的aspx
<body>
    <form id="form1" runat="server">
    <div>
    <div>
        <asp:FileUpload ID="FileUpload1" runat="server" /><br />
        <asp:Button ID="btnupload" runat="server" Text="文件上傳"
            onclick="btnupload_Click" />
        <asp:Label ID="lblManager" runat="server" Text="Label"></asp:Label>
        </div>
       
        <div>
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
                <Columns>
                    <asp:BoundField DataField="name" HeaderText="文件名稱" />
                    <asp:BoundField DataField="extends" HeaderText="文件后綴名稱" />
                    <asp:BoundField DataField="length" HeaderText="文件大小" />
                    <asp:TemplateField HeaderText="下載">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton1" runat="server"
                                CommandArgument='<%# Eval("Fullname") %>' oncommand="LinkButton1_Command">LinkButton</asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
        </div>
   
    </div>
    </form>
</body>
下面是文件的aspx.cs
 protected void LinkButton1_Command(object sender, CommandEventArgs e)
    {
        Response.Clear();
        string path = e.CommandArgument.ToString();
        Response.AddHeader("Content-disposition", "Attachment;filename=" + HttpUtility.UrlEncode(path));
        Response.WriteFile(path);
        Response.End();
 }
 

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多