Ejemplo n.º 1
0
        public static void BatchCopyFileToNewPathInCurrentTab(TabPage tabToCopy)
        {
            ucMovieList movieList = null;

            foreach (Control ctl in tabToCopy.Controls)
            {
                if (ctl is ucMovieList)
                {
                    movieList = (ucMovieList)ctl;
                    break;
                }
            }
            if (movieList == null)
            {
                return;
            }

            // Get New File Path To Copy
            FolderBrowserDialog dir2write = new FolderBrowserDialog();

            if (dir2write.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }
            that.DebugAndLog("Selected destination folder = " + dir2write.SelectedPath);

            // Begin Copy File To New Path
            frmCopyFileStatus frmStatus = new frmCopyFileStatus();

            frmStatus.pathToWrite = dir2write.SelectedPath;
            frmStatus.listMovie   = movieList.GetListMovie();
            frmStatus.Show();
        }
Ejemplo n.º 2
0
        public static void BatchDeleteLastFilePathInCurrentTab(TabPage tabToDelete)
        {
            ucMovieList movieList = null;

            foreach (Control ctl in tabToDelete.Controls)
            {
                if (ctl is ucMovieList)
                {
                    movieList = (ucMovieList)ctl;
                    break;
                }
            }
            if (movieList == null)
            {
                return;
            }

            // Begin Delete Last File Path
            List <MovieProfile> listMovie = movieList.GetListMovie();

            if (listMovie.Count > 0)
            {
                if (MessageBox.Show(
                        "Are you sure to delete " + listMovie.Count.ToString() + " movie File Path!!",
                        " Confirm?", MessageBoxButtons.OKCancel
                        ) != DialogResult.OK)
                {
                    return;
                }
            }

            // After Confirm Begin Real Delete
            int countSuccess = 0;

            for (int i = 0; i < listMovie.Count; i++)
            {
                MovieProfile profile = (MovieProfile)listMovie[i];

                //--------------------------------------------------
                string filePath2Delete = profile.FilePath;
                if (File.Exists(filePath2Delete))
                {
                    try
                    {
                        File.Delete(filePath2Delete);
                        that.DebugAndLog("Delete RealFileInDisk [" + filePath2Delete + "] Success");
                    }
                    catch (Exception ex)
                    {
                        that.DebugAndLog("Error in delete RealFileInDisk [" + filePath2Delete + "] " + ex.Message);
                    }
                }
                profile.FilePath = "";      // Delete from Object
                profile.CheckFileConnect();
                //--------------------------------------------------

                if (!MovieDB.SaveMovieProfile(profile))
                {
                    that.DebugAndLog("Error in MovieDB.SaveMovieProfile() ... Cannot Remove Last FilePath");
                }
                else
                {
                    that.DebugAndLog("Delete last File path from Movie{" + profile.Hash + "} Success");
                    countSuccess++;
                }
            }
            MessageBox.Show("Success delete " + countSuccess.ToString() + " LastFile Path from " + listMovie.Count.ToString() + " profile");
        }