tytd/Tesses.YouTubeDownloader.Ex.../Tesses.YouTubeDownloader.Tools/Tesses.YouTubeDownloader.To.../StringUtils.cs

18 lines
489 B
C#
Raw Normal View History

2022-07-06 22:59:50 +00:00
using System.Text;
namespace Tesses.YouTubeDownloader.Tools.Common
{
public static class StringUtils
{
public static string GetSafeFileName(this string filename)
{
StringBuilder b=new StringBuilder(filename);
foreach(var badChr in "\\\"\'/?*<>|:")
{
b.Replace(badChr.ToString(),"");
}
if(b.Length == 0) return "file";
return b.ToString();
}
}
}