Files
netch/Netch/Forms/Mode/ModeEditorUtils.cs
ChsBuffer 94796110d5 Refactor Mode Form
Process Mode Form Scan to Select
Remove UseCustomName
Mode.get_FullRule throw MessageException
2021-03-13 02:27:38 +08:00

27 lines
709 B
C#

using System.IO;
using System.Text;
namespace Netch.Forms.Mode
{
public static class ModeEditorUtils
{
public static string ToSafeFileName(string text)
{
var fileName = new StringBuilder(text);
foreach (var c in Path.GetInvalidFileNameChars())
fileName.Replace(c, '_');
return fileName.ToString();
}
public static string GetCustomModeRelativePath(string name)
{
if (name == string.Empty)
return string.Empty;
var safeFileName = ToSafeFileName(name);
var relativePath = $"Custom\\{safeFileName}.txt";
return relativePath;
}
}
}