Пример #1
0
        private Result GetOverwriteResult(SourceTarget source
                                          , IFileInfo target)
        {
            Result result = Result.Yes;

            if (target.Exists)
            {
                result = Result.No;

                if (Overwrite == OverwriteOptionConstants.Ask)
                {
                    Int64 startTicks = DateTime.Now.Ticks;

                    result = UIServices.ShowMessageBox("Overwrite \"" + target.FullName + "\"\nfrom \"" + source.SourceFile.FullName + "\"?", "Overwrite?", Buttons.YesNoCancel, Icon.Question);

                    Int64 endTicks = DateTime.Now.Ticks;

                    TimeSpan span = new TimeSpan(endTicks - startTicks);

                    CopyPaused?.Invoke(this, new EventArgs <TimeSpan>(span));
                }
                else if (Overwrite == OverwriteOptionConstants.Always)
                {
                    result = Result.Yes;
                }
            }

            return(result);
        }
Пример #2
0
        private void EnsureSubFolders(SourceTarget fileInfo)
        {
            String directoryName = fileInfo.SourceFile.FolderName;

            String newPath;

            if (directoryName.StartsWith(Properties.Settings.Default.SourcePath))
            {
                newPath = directoryName.Replace(Properties.Settings.Default.SourcePath, String.Empty);
            }
            else
            {
                Int32 indexOfFirstBackSlash;

                indexOfFirstBackSlash = directoryName.IndexOf(@"\");

                newPath = directoryName.Substring(indexOfFirstBackSlash + 1);
            }

            if (IgnoreResolutionFolders)
            {
                if ((newPath.EndsWith(@"\SD")) || (newPath.EndsWith(@"\HD")))
                {
                    newPath = newPath.Substring(0, newPath.Length - 3);
                }
            }

            String path = IOServices.Path.Combine(TargetLocation, newPath);

            fileInfo.TargetFolder = IOServices.GetFolderInfo(path);

            if (fileInfo.TargetFolder.Exists == false)
            {
                fileInfo.TargetFolder.Create();
            }
        }