Unity3D C#脚本获取指定目录所有指定类型文件并改名

C#

浏览数:141

2019-8-30

AD:资源代下载服务
using UnityEngine;
using System.IO;

public class ReName : MonoBehaviour {
    public string pathA = "/Resources/lab/A";
    public string pathB = "/Resources/lab/B";
    void Start () {
        ChangFileName(pathA);
        ChangFileName(pathB);
    }
    
    void ChangFileName (string path) {
        string FullPath = Application.dataPath + path;
#if UNITY_EDITOR
        DirectoryInfo folder = new DirectoryInfo(FullPath);
        foreach (FileInfo file in folder.GetFiles("*.png"))
        {
            file.MoveTo(FullPath+"/"+file.Name.Split('_')[2]);
        }
#endif
    }
}

Tips:
C#获取文件夹下的所有文件的文件名
C#实现文件改名

作者:雨落随风