Unity get folder content

if you want to get the content, first you need know the correct path format.

1
2
3
4
5
filePath = "/storage/emulated/0/Download"; // in oculus quest2
if (Application.isEditor)
{
filePath = "D:\\test"; // in windows
}

get files from target path

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
public string getUrl(string path)
{
var info = new DirectoryInfo(path);
var files = info.GetFiles();
string targetUrl = "";
string result = "";
foreach (var item in files)
{
result += item;
if (item.ToString().Contains("mp4"))
{
targetUrl = item.ToString();
}
}
Debug.Log(result);
return targetUrl;
}