ball 项目提交
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BallKingdomCrush.Editor
|
||||
{
|
||||
public static class FileKit
|
||||
{
|
||||
public static void CreateTxt(string path, string Txt, bool IsCover = false, bool IsAssetPath = false)
|
||||
{
|
||||
if (IsAssetPath)
|
||||
{
|
||||
path = Application.dataPath.Replace("Assets", string.Empty) + path;
|
||||
}
|
||||
|
||||
if (!Directory.Exists(GetFullDiretoryPath(path)))
|
||||
{
|
||||
Directory.CreateDirectory(GetFullDiretoryPath(path));
|
||||
}
|
||||
|
||||
if (File.Exists(path))
|
||||
{
|
||||
if (!IsCover)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
File.Delete(path);
|
||||
}
|
||||
|
||||
File.WriteAllText(path, Txt, new UTF8Encoding(false));
|
||||
}
|
||||
|
||||
public static string GetFullDiretoryPath(string filePath)
|
||||
{
|
||||
string fileName = Path.GetFileName(filePath);
|
||||
return filePath.Replace(fileName, string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user