Example #1
0
        DirectoryInfoEx PrepateDirectoryForCopy(DirectoryInfoEx srcDir, DirectoryInfoEx baseDir, string dirName)
        {
            bool isDirectory;

            if (!baseDir.Exists)
            {
                baseDir.Create();
            }
            if (baseDir.Contains(dirName, out isDirectory))
            {
                FileSystemInfoEx destSubItem = baseDir[dirName];

                if (!isDirectory)
                {
                    OverwriteMode overwrite = AskOverwrite(srcDir, destSubItem);
                    switch (overwrite)
                    {
                    case OverwriteMode.KeepOriginal:
                        return(null);

                    case OverwriteMode.Replace:
                        destSubItem.Delete();
                        return(baseDir.CreateDirectory(dirName));
                    }
                    throw new NotImplementedException("OverwriteMode");
                }
                else
                {
                    return(destSubItem as DirectoryInfoEx);
                }
            }
            else
            {
                return(baseDir.CreateDirectory(dirName));
            }
        }
Example #2
0
        DirectoryInfoEx PrepateDirectoryForCopy(DirectoryInfoEx srcDir, DirectoryInfoEx baseDir, string dirName)
        {
            bool isDirectory;
            if (!baseDir.Exists)
                baseDir.Create();
            if (baseDir.Contains(dirName, out isDirectory))
            {
                FileSystemInfoEx destSubItem = baseDir[dirName];

                if (!isDirectory)
                {
                    OverwriteMode overwrite = AskOverwrite(srcDir, destSubItem);
                    switch (overwrite)
                    {
                        case OverwriteMode.KeepOriginal :
                            return null;
                        case OverwriteMode.Replace :
                            destSubItem.Delete();
                            return baseDir.CreateDirectory(dirName);
                    }
                    throw new NotImplementedException("OverwriteMode");
                }
                else return destSubItem as DirectoryInfoEx;
            }
            else return baseDir.CreateDirectory(dirName);
        }