mirror of
https://github.com/netchx/netch.git
synced 2026-03-14 17:43:18 +08:00
25 lines
624 B
C#
25 lines
624 B
C#
using System.Text;
|
|
|
|
namespace Netch.Forms.ModeForms;
|
|
|
|
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}.json";
|
|
return relativePath;
|
|
}
|
|
} |