Search
 
SCRIPT & CODE EXAMPLE
 

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"
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# print out 
Csharp :: how to reference scripts in other scenes unity 
Csharp :: c# how to add newline on text box 
Csharp :: c# run c# code from string 
Csharp :: how to do cmd command c# 
Csharp :: wpf choose file dialog 
Csharp :: asp.net list all files in folder 
Csharp :: unity mouse wheel 
Csharp :: unity movetowards 2d 
Csharp :: unity object follow mouse 
Csharp :: get the path of executable c# 
Csharp :: delay in unity 
Csharp :: c# count specific element in list 
Csharp :: this site can’t be reachedlocalhost unexpectedly closed the connection. .net framework 
Csharp :: c# get file extension 
Csharp :: Set value into lookup field in console app using dynamic CRM 365 
Csharp :: unity gameobject.find not working 
Csharp :: Exit string qoutes c# 
Csharp :: restart wpf application 
Csharp :: How To Get The Global Position of a GameObject in a Variable 
Csharp :: make mesh follow wheel collider unity 
Csharp :: check internet connection in c# 
Csharp :: bluestacks unity black screen 
Csharp :: c# convert enum to list 
Csharp :: game object find 
Csharp :: get item from icollection 
Csharp :: remove items from list c# condition 
Csharp :: unity lock cursor to center 
Csharp :: How to get the world position of the edge of an object? 
Csharp :: what is data encapsulation c# 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =