C#顯示文件夾下所有圖片文件的方法
更新時間:2015年04月22日 12:08:17 作者:songguo
這篇文章主要介紹了C#顯示文件夾下所有圖片文件的方法,涉及C#操作圖片文件的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下
本文實例講述了C#顯示文件夾下所有圖片文件的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:
<%@ Page Language="C#" EnableViewState="false" %> <%@ Import Namespace="System.IO" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { FileInfo[] fs1 = (new DirectoryInfo(Server.MapPath("~/A"))).GetFiles(); FileInfo[] fs2 = (new DirectoryInfo(Server.MapPath("~/B"))).GetFiles(); FileInfo[] fs3 = (new DirectoryInfo(Server.MapPath("~/C"))).GetFiles(); FileInfo[] fs4 = (new DirectoryInfo(Server.MapPath("~/D"))).GetFiles(); FileInfo[] fs5 = (new DirectoryInfo(Server.MapPath("~/E"))).GetFiles(); var fs = fs1.Concat(fs2).Concat(fs3).Concat(fs4).Concat(fs5); Repeater1.DataSource = fs; Repeater1.DataBind(); } string GetUrl(object img) { FileInfo f = img as FileInfo; return Page.ResolveUrl("~")+f.DirectoryName.Substring(f.DirectoryName.LastIndexOf("\")+1)+"/"+f.Name; } </script> <html> <head> <title></title> </head> <body> <form id="form1" runat="server"> <asp:Repeater ID="Repeater1" runat="server"> <ItemTemplate> <div><a href='<%#GetUrl(Container.DataItem) %>'> <img src='<%#GetUrl(Container.DataItem) %>' /></a></div> </ItemTemplate> </asp:Repeater> </form> </body> </html>
希望本文所述對大家的C#程序設(shè)計有所幫助。
相關(guān)文章
winform實現(xiàn)關(guān)閉按鈕失效的兩種方法
這篇文章主要介紹了winform實現(xiàn)關(guān)閉按鈕失效的兩種方法,實例分析了WinForm實現(xiàn)關(guān)閉按鈕失效的原理與所涉及的相關(guān)技巧,需要的朋友可以參考下2015-09-09C# winform 請求http的實現(xiàn)(get,post)
本文主要介紹了C# winform 請求http的實現(xiàn)(get,post),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2022-06-06C#中Override關(guān)鍵字和New關(guān)鍵字的用法詳解
這篇文章主要介紹了C#中Override關(guān)鍵字和New關(guān)鍵字的用法,需要的朋友可以參考下2016-01-01