Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

get random file in directory c#

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"
 
PREVIOUS NEXT
Tagged: #random #file #directory
ADD COMMENT
Topic
Name
6+8 =