1234567891011121314151617181920212223242526272829303132333435363738394041 |
- using System;
- namespace labelUtility
- {
- using System.IO;
- using UnityEngine;
- public static class ExPath
- {
- public static string GetRelativePath(this string path)
- {
- return "Assets" + path.Replace(Application.dataPath, "");
- }
- public static string GetUnRepeatFileName(this string fileName)
- {
- string extension = Path.GetExtension(fileName);
- string directory = Path.GetDirectoryName(fileName);
- string name = Path.GetFileNameWithoutExtension(fileName);
- int count = 0;
- string newFileName = string.Format("{0}/{1}{2}", directory, name, extension);
- while (File.Exists(newFileName))
- {
- count++;
- newFileName = string.Format("{0}/{1} ({2}){3}", directory, name, count, extension);
- }
- return newFileName;
- }
- }
- }
|