📜  在目录c#代码示例中获取随机文件

📅  最后修改于: 2022-03-11 14:49:19.885000             🧑  作者: Mango

代码示例1
using System.IO;
using System.Collections;

var files = Directory.GetFiles("C:/path_example/example", "*.png"); //.png can be changed to match any other desired extentions
string randomFilePath= files[Random.Range(0,files.Length)];
//example output: "C:/path_example/example/pig4.png"