zoukankan      html  css  js  c++  java
  • unity文件夹复制

    如果是编辑器不使用运行时的话,直接使用UnityEditor下的API即可

    FileUtil.CopyFileOrDirectory

    如果是运行时

        /// <summary>
        /// 文件夹拷贝
        /// </summary>
        /// <param name="sourcePath">源路径</param>
        /// <param name="destPath">目标路径</param>
        private void CopyFolder(string sourcePath, string destPath)
        {
            if (Directory.Exists(sourcePath))
            {
                if (!Directory.Exists(destPath))
                {
                    try
                    {
                        Directory.CreateDirectory(destPath);
                    }
                    catch (Exception ex)
                    {
                        Debug.LogError("创建失败");
                    }
                }
                
                List<string> files = new List<string>(Directory.GetFiles(sourcePath));
                files.ForEach(c =>
                {
                    //排除meta文件
                    if (!c.EndsWith(".meta"))
                    {
                        string destFile = Path.Combine(destPath, Path.GetFileName(c));
                        File.Copy(c, destFile, true);
                    }
                });
                List<string> folders = new List<string>(Directory.GetDirectories(sourcePath));
                folders.ForEach(c =>
                {
                    string destDir = Path.Combine(destPath,Path.GetFileName(c));
                    CopyFolder(c, destDir);
                });
            }
            else
            {
                Debug.LogError("源目录不存在");
            }
        }
    
    
  • 相关阅读:
    linux防火墙关闭与中文显示乱码排错
    linux基础命令
    盒子模块
    表的数据类型
    pymysql模块
    sql综合练习题
    pymysql内置功能
    数据操作
    vue 左侧菜单展示,以及对应的路由配置
    vue 左侧菜单路由实现
  • 原文地址:https://www.cnblogs.com/sanyejun/p/14450962.html
Copyright © 2011-2022 走看看