2024-09-01 23:25:50 +03:00

24 lines
526 B
C#

using System.Collections.Generic;
using System.IO;
using System.Text;
namespace YoutubeDownloader.Core.Utils;
public static class PathEx
{
private static readonly HashSet<char> InvalidFileNameChars =
[
.. Path.GetInvalidFileNameChars(),
];
public static string EscapeFileName(string path)
{
var buffer = new StringBuilder(path.Length);
foreach (var c in path)
buffer.Append(!InvalidFileNameChars.Contains(c) ? c : '_');
return buffer.ToString();
}
}