好的,可以说我们有这个层次结构:ParentFolder> ChildFolder> Files
我想检查ParentFolder是否存在,如果存在,则获取ChildFolder中的文件。我到目前为止得到的是
string MainFolderPaths = Application.persistentDataPath + "/ParentFolder";
//Check existence of folder
if (Directory.Exists(MainFolderPaths))
{
msgText.text = "Folder exist";
//Returns the subdirectories in MainFolderPaths
MainFolderDirectory = Directory.GetDirectories(MainFolderPaths);
//Go through the folders that exist in the MainFolderDirectory
foreach(var folder in MainFolderDirectory)
{
//Get the files that are in each folder
string[] files = Directory.GetFiles(folders);
//Go through the files
foreach(string file in files)
{
//read text file here
}
}
}
else
{
msgText.text = "No folder found.";
}
我已经更新了代码。我想知道我在做什么吗?如果这是正确的,那么我可能正在读取错误的文件。