1 /// <summary> 2 /// 3 /// </summary> 4 /// <param name="sender"></param> 5 /// <param name="e"></param> 6 protected void Page_Load(object sender, EventArgs e) 7 { 8 if (!IsPostBack) 9 { 10 path = Server.MapPath("images/"); 11 12 String searchFolder = path; 13 String[] filters = new String[] { "jpg", "jpeg", "png", "gif", "tiff", "bmp" }; 14 String[] files = GetFilesFrom(searchFolder, filters, false); 15 for (int i = 0; i < files.Length; i++) 16 { 17 Response.Write(files[i].ToString()+"<br/>"); 18 } 19 20 21 } 22 23 24 } 25 /// <summary> 26 /// 查找文件夾下的圖片 27 /// 2014-08-28 28 /// 塗聚文 29 /// </summary> 30 /// <param name="searchFolder"></param> 31 /// <param name="filters"></param> 32 /// <param name="isRecursive"></param> 33 /// <returns></returns> 34 public static String[] GetFilesFrom(String searchFolder, String[] filters, bool isRecursive) 35 { 36 List<String> filesFound = new List<String>(); 37 SearchOption searchOption = isRecursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly; 38 foreach (string filter in filters) 39 { 40 filesFound.AddRange(Directory.GetFiles(searchFolder, String.Format("*.{0}", filter), searchOption)); 41 } 42 return filesFound.ToArray(); 43 }
java的環境變量配了嗎?
這個文件路徑改成你的jre路徑,在安裝tomcat時候可以改這個的。
在第15張幻燈片給出文件和文件夾,假定當前的工作目錄是:"C:\WP\Backup"。
別只復制一句話啊,一段發上來,比較好翻譯。