mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-15 15:57:52 +08:00
Make InputFieldRef helper, InteractiveString and IOUtility
This commit is contained in:
29
src/Core/Utility/IOUtility.cs
Normal file
29
src/Core/Utility/IOUtility.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace UnityExplorer
|
||||
{
|
||||
public static class IOUtility
|
||||
{
|
||||
public static string EnsureValid(string path)
|
||||
{
|
||||
path = RemoveInvalidChars(path);
|
||||
|
||||
var dir = Path.GetDirectoryName(path);
|
||||
|
||||
if (!Directory.Exists(dir))
|
||||
Directory.CreateDirectory(dir);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
public static string RemoveInvalidChars(string path)
|
||||
{
|
||||
return string.Concat(path.Split(Path.GetInvalidPathChars()));
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user