如何识别文件夹中的最后一个文件 [英] how to identify last file in a folder

查看:100
本文介绍了如何识别文件夹中的最后一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何识别文件夹中的最后一个图像文件,我想从头到尾循环播放文件夹中的所有图像文件,并且需要将这些图像放置在图像框中

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

推荐答案

有趣的问题.什么定义了最后一个文件?它是最后添加的文件吗?它是名称中的最后一个文件吗?如果顺序颠倒了怎么办?

无论如何,您实际上不必为此担心.您可以使用Directory类让.NET框架为您处理它.这是您的操作方法:
Interesting question. What defines the last file? Is it that it was the last file added? Is it the last file by name? What about if the order is reversed?

Anyway, you don''t actually need to worry about this. You can let the .NET framework take care of it for you using the Directory class. Here''s how you would do it:
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. :)



这是什么问题?
What''s the problem with this?
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.



这篇关于如何识别文件夹中的最后一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆