简体   繁体   中英

Get images from all folders that are in another folder

我需要将所有图像显示在图库页面上,但是我不知道如何从子文件夹中获取图像,因为它们的ID都不同,例如1,2,3,4,5,6他们所在的文章。

string path = Server.MapPath("~/images");
private string[] imgFiles = Directory.GetFiles(path, "*.png")
                                 .Select(path => Path.GetFileName(path))
                                 .ToArray();

just on a quick search i got

string[] filePaths = Directory.GetFiles(@"c:\MyDir\", "*.bmp",SearchOption.AllDirectories);

All you need to do is edit it and add the different types your immages could be

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM