- Home /
Return Folder Name In String
Hey Guys! Creeperbot65 here!
I'm having trouble trying to get the FOLDER name from a directory. Here's the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.IO;
public class LoadGameFolders : MonoBehaviour {
public Dropdown GameList;
void Awake () {
DirectoryInfo dir = new DirectoryInfo(Application.streamingAssetsPath);
DirectoryInfo[] info = dir.GetDirectories ();
foreach (DirectoryInfo f in info)
{
List<string> DDList = new List<string>() { };
}
}
}
Thanks!
-creeperbot65
Comment
Best Answer
Answer by SeaPeaMe · Jan 15, 2018 at 11:56 PM
Never Mind! I found out that all you had to do was put f.Name between the Curly Brackets ( { } )
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.IO;
public class LoadGameFolders : MonoBehaviour {
public Dropdown GameList;
void Awake () {
DirectoryInfo dir = new DirectoryInfo(Application.streamingAssetsPath);
DirectoryInfo[] info = dir.GetDirectories ();
foreach (DirectoryInfo f in info)
{
List<string> DDList = new List<string>() { f.Name };
GameList.AddOptions(DDList);
}
}
}
Your answer

Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How do you check if a directory exists c#? 2 Answers
Distribute terrain in zones 3 Answers
What is the equivalent of EditorUtility.OpenFolderPanel for runtime? 0 Answers
Move files from folder a to folder b 1 Answer