微调自定义路径

This commit is contained in:
Genteure 2020-04-26 13:00:10 +08:00
parent bcb78ccf42
commit e02f96dcd8
2 changed files with 4 additions and 1 deletions

View File

@ -449,6 +449,7 @@ namespace BililiveRecorder.Core
if (!filename.EndsWith(".flv", StringComparison.OrdinalIgnoreCase))
filename += ".flv";
filename = filename.RemoveInvalidFileName(ignore_slash: true);
filename = Path.Combine(_config.WorkDirectory, filename);
filename = Path.GetFullPath(filename);

View File

@ -40,10 +40,12 @@ namespace BililiveRecorder.Core
}
}
internal static string RemoveInvalidFileName(this string name)
internal static string RemoveInvalidFileName(this string name, bool ignore_slash = false)
{
foreach (char c in Path.GetInvalidFileNameChars())
{
if (ignore_slash && (c == '\\' || c == '/'))
continue;
name = name.Replace(c, '_');
}
return name;