using System.Text.RegularExpressions; namespace ZonyLrcTools.Common { /// /// 歌曲信息的承载类,携带歌曲的相关数据。 /// public partial class MusicInfo { /// /// 歌曲对应的物理文件路径。 /// public string FilePath { get; } /// /// 歌曲的实际歌曲长度。 /// public long? TotalTime { get; set; } /// /// 歌曲的名称。 /// public string Name { get; set; } /// /// 歌曲的作者。 /// public string Artist { get; set; } /// /// 是否下载成功? /// public bool IsSuccessful { get; set; } = true; /// /// 是否时纯音乐? /// public bool IsPruneMusic { get; set; } = false; /// /// 构建一个新的 对象。 /// /// 歌曲对应的物理文件路径。 /// 歌曲的名称。 /// 歌曲的作者。 public MusicInfo(string filePath, string name, string artist) { FilePath = Path.Combine(Path.GetDirectoryName(filePath)!, HandleInvalidFilePath(Path.GetFileName(filePath))); Name = name; Artist = artist; } private string HandleInvalidFilePath(string srcText) { return InvalidFilePathRegex().Replace(srcText, ""); } [GeneratedRegex(@"[<>:""/\\|?*]")] private static partial Regex InvalidFilePathRegex(); } }