Exemple #1
0
        public static bool ConvertFileNameAt(int index)
        {
            string    newFileName = string.Empty;
            FileMusic muFile      = (FileMusic)FileLists.ElementAt(index);

            if (string.IsNullOrEmpty(muFile.Artist) && string.IsNullOrEmpty(muFile.Title))
            {
                newFileName = muFile.FileName;
            }
            else
            {
                newFileName = string.Concat("[", muFile.Artist, "]", muFile.Title, ".mp3");
            }

            if (SavePath.Equals(string.Empty))
            {
                return(false);
            }

            if (!Directory.Exists(@SavePath))
            {
                Directory.CreateDirectory(@SavePath);
            }

            try
            {
                var sourceFile = string.Concat(FileLists.ElementAt(index).FilePath, "\\", FileLists.ElementAt(index).FileName);

                File.Copy(sourceFile, string.Concat(@SavePath, "//", newFileName), true);
                File.Delete(sourceFile);
            }
            catch (Exception ex)
            {
            }

            return(true);
        }