【发布时间】:2011-08-05 13:56:28
【问题描述】:
我需要读取一些目录,问题是我需要按文件名进行过滤。
示例:"1000123107.jpg"、"1700123107.jpg"、"1005123101.jpg"、"1077123107.jpg",在这种情况下,我需要获取以字符 "7.jpg" 结尾的图像:仅"1000123107.jpg",我尝试使用这个:
string[] filePaths = System.IO.Directory.GetFiles(
filePath + "\\", "*7.jpg", SearchOption.AllDirectories);
但不起作用,因为这也会得到其他在开头或中间有 "7" 的图像。
("1000123107.jpg" 和 "1700123107.jpg" 和 "1077123107.jpg")所以这是错误的!
我只需要返回"1000123107.jpg"。
请有人告诉我该怎么做?
谢谢。
【问题讨论】:
-
这听起来可能很愚蠢,但您的排序标准有点奇怪。为什么不让七人组出现在任何其他位置,只要他们也是最后一个角色?
-
不管名字有其他7个,如果重要的话以7.jpg结尾
-
那我不明白这个说法:
But not work, because that get also other images that have a "7" at begin or in the middle. ("1000123107.jpg" and "1700123107.jpg" and "1077123107.jpg") so thats is wrong!!