[英]Order string[] path from filename c#
I have a problem with my software, I need to order a series of .mp4 video that are located in different folders. 我的软件有问题,我需要订购一系列位于不同文件夹中的.mp4视频。
Now I'm able to retrieve all videos with this instruction: 现在我可以使用此说明检索所有视频:
string[] video = Directory.GetFiles("..\\..\\", "*.mp4", SearchOption.AllDirectories);
But I have not my video ordered by name, they are ordered by folder. 但我没有按照名称订购我的视频,它们按文件夹排序。
Any idea? 任何想法?
Thanks 谢谢
您可以使用
video.OrderBy(Path.GetFileName).ToArray();
add the following using statement to your code: 将以下using语句添加到您的代码中:
using System.Linq;
then you can order the array by string: 然后你可以按字符串排序数组:
video = video.OrderBy(x => Path.GetFileName(x)).ToArray();
你可以用这个:
var ordered = video.OrderBy(filename => Path.GetFilename(filename));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.