40 lines
1.0 KiB
C#
40 lines
1.0 KiB
C#
using System.IO;
|
|
using System.Text;
|
|
using UnityEngine;
|
|
|
|
namespace BingoBrain.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);
|
|
}
|
|
}
|
|
} |