Exemple #1
0
        /// <summary>
        /// 保存到文件
        /// </summary>
        /// <param name="outputFilePath"></param>
        public void SaveToFile(string outputFilePath)
        {
            var sb = new StringBuilder();

            sb.AppendLine(string.Format("[id:{0}]", this.ID));


            if (!string.IsNullOrEmpty(this.Al))
            {
                sb.AppendLine(string.Format("[al:{0}]", this.Al));
            }

            if (!string.IsNullOrEmpty(this.Ar))
            {
                sb.AppendLine(string.Format("[ar:{0}]", this.Ar));
            }

            if (!string.IsNullOrEmpty(this.Title))
            {
                sb.AppendLine(string.Format("[ti:{0}]", this.Title));
            }

            if (!string.IsNullOrEmpty(this.Hash))
            {
                sb.AppendLine(string.Format("[hash:{0}]", this.Hash));
            }

            if (!string.IsNullOrEmpty(this.By))
            {
                sb.AppendLine(string.Format("[by:{0}]", this.By));
            }

            if (this.Total != TimeSpan.Zero)
            {
                sb.AppendLine(string.Format("[total:{0}]", this.Total.TotalMilliseconds));
            }

            if (this.Offset != TimeSpan.Zero)
            {
                sb.AppendLine(string.Format("[offset:{0}]", this.Offset.TotalMilliseconds));
            }


            foreach (var line in this.Lines)
            {
                sb.AppendLine(line.KRCLineString);
            }


            var bytes = KRCFile.EncodeStringToBytes(sb.ToString());


            File.WriteAllBytes(outputFilePath, bytes);
        }
Exemple #2
0
        /// <summary>
        /// 从文件加载
        /// </summary>
        /// <param name="inputFilePath"></param>
        /// <returns></returns>
        public static KRCLyrics LoadFromFile(string inputFilePath)
        {
            var str = KRCFile.DecodeFileToString(inputFilePath);

            return(LoadFromString(str));
        }