问题描述
我想知道如何识别文件夹中的最后一个图像文件,我想从头到尾循环播放文件夹中的所有图像文件,并且需要将这些图像放置在图像框中
i want to know how to identify a last image file in a folder, i want to loop all the image files in a folder from starting to last and i need to place those images in image box
推荐答案
string[] files = Directory.GetFiles(@"c:\myimages", "*.jpg");
-----------------
来自JSOP:调用GetFiles时,文件夹中的最后一个文件是列表中的最后一个文件.文件以自然"顺序存储(文件放置/复制到磁盘的顺序).放置在磁盘上的最后一个也不一定具有最新的修改日期.您可以感谢发明了DOS的小家伙. :)
-----------------
From JSOP: The last file in the folder is the last one in the list when you do a GetFiles call. Files are stored in a "natural" order (the order the were placed/copied to the disk). The last one placed on the disk will NOT necessarily have the newest modification date, either. You can thank the guys that invented DOS for this little gem. :)
string[] files = Directory.GetFiles(path);
count = files.length;
-----------------
来自JSOP:我认为他只是想知道他何时到达上一个文件.他可以使用Pete引用的方法来做到这一点,并迭代返回的字符串数组,直到到达最后一个项目.
-----------------
From JSOP: I think he just wanted to know when he got to the last file. He can do that by using the method cited by Pete, and the iterate through the returned string array until he reaches the last item.
这篇关于如何识别文件夹中的最后一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!