Beispiel #1
0
    // 得到指定目录下的所有第一级子目录
    // path为绝对路径
    public static bool findFolders(string path, List <string> dirList, bool recursive = true)
    {
        validPath(ref path);
        if (!isDirExist(path))
        {
            return(false);
        }
#if UNITY_ANDROID && !UNITY_EDITOR
        AndroidAssetLoader.findFolders(path, dirList, recursive);
#else
        // 非安卓平台则查找普通文件夹
        string[] dirs  = Directory.GetDirectories(path);
        int      count = dirs.Length;
        for (int i = 0; i < count; ++i)
        {
            string dir = dirs[i];
            dirList.Add(dir);
            if (recursive)
            {
                findFolders(dir, dirList, recursive);
            }
        }
#endif
        return(true);
    }
    // 得到指定目录下的所有第一级子目录
    // path为绝对路径
    public static bool findFolders(string path, List <string> dirList, bool recursive = true)
    {
        validPath(ref path);
        if (!isDirExist(path))
        {
            return(false);
        }
#if UNITY_ANDROID && !UNITY_EDITOR
        AndroidAssetLoader.findFolders(path, dirList, recursive);
#else
        // 非安卓平台则查找普通文件夹
        string[] dirs = Directory.GetDirectories(path);
        foreach (var item in dirs)
        {
            dirList.Add(item);
            if (recursive)
            {
                findFolders(item, dirList, recursive);
            }
        }
#endif
        return(true);
    }