csharp

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

2017-08-10  本文已影响22人  雨落随风
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#实现文件改名

上一篇下一篇

猜你喜欢

热点阅读