Files
BingoGrassland/Assets/Editor/Scripts/FileKit.cs
T

40 lines
1.0 KiB
C#
Raw Normal View History

2026-04-20 13:49:36 +08:00
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);
}
}
}