Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="folderPath">".\\"或"C:\sss\"</param>
        /// <param name="filenamePatern">"[title].lrc"支援[track number][title][artist][album]</param>
        public LyricsFileWriter(string folderPath, string filenamePatern, NeteaseMusic.Music music, string fileEncoding = "UTF-8", int totalWidth = 2)
        {
            if (!folderPath.EndsWith(@"\"))
            {
                folderPath += @"\";
            }
            this.folderPath = folderPath;
            if (!System.IO.Directory.Exists(folderPath))
            {
                System.IO.Directory.CreateDirectory(folderPath);
            }
            this.fileEncoding = fileEncoding;

            //当获取不到Title的时候,直接以ID号命名。
            if (music.Title == null || music.Title == "")
            {
                fileName = music.ID.ToString() + ".lrc";
                return;
            }

            fileName = filenamePatern;//结尾应该为.lrc
            fileName = fileName.Replace("[track number]", music.Index.ToString().PadLeft(totalWidth, '0'));
            fileName = fileName.Replace("[title]", music.Title);
            fileName = fileName.Replace("[artist]", music.Artist);
            fileName = fileName.Replace("[album]", music.Album);
            fileName = FormatFileName.CleanInvalidFileName(fileName);
        }
Exemplo n.º 2
0
 const string Bar = "SongNum|SongID      |SongName                                          |SongAlbum                               |SongArtist                    |LrcSts         |ErrorInfo"; //string.Format("{0,-7}|{1,-12}|{2,-50}|{3,-40}|{4,-30}|{5,-15}|ErrorInfo", "SongNum", "SongID", "SongName", "SongAlbum", "SongArtist","LrcSts");
 public LogFileWriter(string folderPath, string fileName = "Log.txt", string fileEncoding = "UTF-8")
 {
     if (!folderPath.EndsWith(@"\"))
     {
         folderPath += @"\";
     }
     this.folderPath = folderPath;
     if (!System.IO.Directory.Exists(folderPath))
     {
         System.IO.Directory.CreateDirectory(folderPath);
     }
     fileName          = FormatFileName.CleanInvalidFileName(fileName);
     this.fileName     = fileName;
     this.fileEncoding = fileEncoding;
     log.Add(HEAD_DESCRIPTION);
     for (int i = 0; i < 2; i++)
     {
         log.Add("");
     }
 }