Esempio n. 1
0
        public static void CopyDirectoryTo(this FsPath path, FsPath other, bool overwrite)
        {
            foreach (FsPath dirPath in path.EnumerateDirectories("*", SearchOption.AllDirectories).ToArray())
            {
                dirPath.ChangeDirectory(path, other).CreateDirectory();
            }

            foreach (FsPath newPath in path.EnumerateFiles("*", SearchOption.AllDirectories))
            {
                newPath.CopyFileTo(newPath.ChangeDirectory(path, other), overwrite);
            }
        }
Esempio n. 2
0
        public static void EnsureEmptyDirectory(this FsPath path)
        {
            if (!path.IsDirectory())
            {
                path.CreateDirectory();
                return;
            }

            foreach (var subdirInfo in path.EnumerateDirectories().ToArray())
            {
                subdirInfo.DeleteDirectory(recursive: true);
            }

            foreach (var fileInfo in path.EnumerateFiles().ToArray())
            {
                fileInfo.DeleteFile();
            }
        }