Ejemplo n.º 1
0
        /// <summary>
        /// Сopy the directory with the embedded files and directories
        /// </summary>
        /// <param name="sourcePath">Path to the source directory</param>
        /// <param name="destinationPath">Path to the destination directory</param>
        protected virtual void CopyDirectory(string sourcePath, string destinationPath)
        {
            string[] existingFiles       = _fileProvider.GetFiles(sourcePath);
            string[] existingDirectories = _fileProvider.GetDirectories(sourcePath);

            if (!_fileProvider.DirectoryExists(destinationPath))
            {
                _fileProvider.CreateDirectory(destinationPath);
            }

            foreach (string file in existingFiles)
            {
                string filePath = _fileProvider.Combine(destinationPath, _fileProvider.GetFileName(file));
                if (!_fileProvider.FileExists(filePath))
                {
                    _fileProvider.FileCopy(file, filePath);
                }
            }

            foreach (string directory in existingDirectories)
            {
                string directoryPath = _fileProvider.Combine(destinationPath, _fileProvider.GetDirectoryName(directory));
                CopyDirectory(directory, directoryPath);
            }
        }