예제 #1
0
        private string CreateUniqueFileName(FileInfo file, string destination)
        {
            string savePath = Path.Combine(destination, file.Name);

            int    fileCount          = 0;
            string fileExt            = "";
            string fileNameWithoutExt = "";

            if (File.Exists(savePath))
            {
                DirectoryInfo dir       = new DirectoryInfo(destination);
                FileInfo[]    saveFiles = dir.GetFiles(file.Name + "*");

                fileNameWithoutExt = FilePathDeconstructor.PathWithoutExt(file.Name);
                fileExt            = FilePathDeconstructor.GetExt(file.Name);
                fileCount          = FolderOperations.CheckFilesWithName(file.Name, destination);

                savePath = Path.Combine(destination, String.Format("{0}({1}).{2}", fileNameWithoutExt, fileCount, fileExt));
            }

            while (File.Exists(savePath))
            {
                fileCount++;
                savePath = Path.Combine(destination, String.Format("{0}({1}).{2}", fileNameWithoutExt, fileCount, fileExt));
            }

            return(savePath);
        }
예제 #2
0
        private async void uxCopyButton_ClickAsync(object sender, EventArgs e)
        {
            if (uxSource.Text != String.Empty && uxDest.Text != String.Empty)
            {
                ResetUI();
                _operationInProgress = true;

                progress.Show();

                DirectoryInfo dir  = new DirectoryInfo(uxSource.Text);
                Task <bool>   test = await Task.Factory.StartNew(() => MoveFolder(dir, uxDest.Text));

                FolderOperations.RemoveEmptyFolders(uxSource.Text);
                MessageBox.Show("Finished dumping files!");

                _operationInProgress = false;
                progress.Hide();

                ResetUI();
            }
        }
예제 #3
0
 /// <summary>
 /// Resets the progress bar to its idle state
 /// </summary>
 private void ResetProgress()
 {
     progress.Reset(FolderOperations.CalculateNumFiles(uxSource.Text, true));
 }