I have a problem with my software, I need to order a series of .mp4 video that are located in different folders.
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 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));
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.