1、判断该文件是否为需要的文件
static bool IsVideoFile(string extension)
{
return extension.Equals(".avi", StringComparison.OrdinalIgnoreCase) ||
extension.Equals(".mp4", StringComparison.OrdinalIgnoreCase) ||
extension.Equals(".mov", StringComparison.OrdinalIgnoreCase) ||
extension.Equals(".wmv", StringComparison.OrdinalIgnoreCase) ||
extension.Equals(".mkv", StringComparison.OrdinalIgnoreCase);
}
2、加载文件夹
List<FileInfo> GetLoadFiles()
{
if (!Directory.Exists(vedioPath))
Directory.CreateDirectory(vedioPath);
DirectoryInfo dri = new DirectoryInfo(vedioPath);
return dri.GetFiles("*.*").Where(files => IsVideoFile(files.Extension)).ToList();
}