コード例 #1
0
        public static bool Rename(MovieModel movie)
        {
            bool renameStatus= false;
            string newFileName = createNewFileName(movie);
            movie.NewFileName = movie.NewFilePath+ "/" + newFileName+ movie.Extenstion;
            Console.WriteLine("Please Confirm filename change from: ");
            Console.WriteLine(movie.OldFileName);
            Console.WriteLine("To: ");
            Console.WriteLine(movie.NewFileName);
            Console.WriteLine("yes or no");
            string userResponse = Console.ReadLine();

            if (userResponse=="yes")
            {
                try
                {
                    System.IO.File.Move(movie.OldFilePath, movie.NewFileName);
                    renameStatus = true;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    renameStatus = false;
                }
            }

            return renameStatus;
        }
コード例 #2
0
        static string createNewFileName(MovieModel movie)
        {
            string fileName = "";

            fileName = movie.Title + "_(" + movie.Year + ")";

            return fileName;
        }