BlogEngine.Core.Packaging.FileSystem.CopyDirectory C# (CSharp) Метод

CopyDirectory() статический приватный Метод

static private CopyDirectory ( DirectoryInfo source, DirectoryInfo target, string pkgId, List installedFiles ) : void
source System.IO.DirectoryInfo
target System.IO.DirectoryInfo
pkgId string
installedFiles List
Результат void
        static void CopyDirectory(DirectoryInfo source, DirectoryInfo target, string pkgId, List<PackageFile> installedFiles)
        {
            var rootPath = HttpContext.Current.Server.MapPath(Utils.RelativeWebRoot);

            foreach (var dir in source.GetDirectories())
            {
                var filePath = Path.Combine(target.FullName, dir.Name);
                var relPath = filePath.Replace(rootPath, "");

                // save directory if it is created by package
                // so we can remove it on package uninstall
                if (!Directory.Exists(filePath))
                {
                    fileOrder++;
                    var fileToCopy = new PackageFile
                    {
                        FilePath = relPath,
                        PackageId = pkgId,
                        FileOrder = fileOrder,
                        IsDirectory = true
                    };
                    installedFiles.Add(fileToCopy);
                }
                CopyDirectory(dir, target.CreateSubdirectory(dir.Name), pkgId, installedFiles);
            }

            foreach (var file in source.GetFiles())
            {
                var filePath = Path.Combine(target.FullName, file.Name);
                var relPath = filePath.Replace(rootPath, "");

                file.CopyTo(filePath);

                fileOrder++;
                var fileToCopy = new PackageFile
                {
                    FileOrder = fileOrder,
                    IsDirectory = false,
                    FilePath = relPath,
                    PackageId = pkgId
                };

                // fix known interface changes
                if (filePath.ToLower().EndsWith(".cs") ||
                    filePath.ToLower().EndsWith(".aspx") ||
                    filePath.ToLower().EndsWith(".ascx") ||
                    filePath.ToLower().EndsWith(".master"))
                {
                    ReplaceInFile(filePath, "BlogSettings.Instance.StorageLocation", "Blog.CurrentInstance.StorageLocation");
                    ReplaceInFile(filePath, "BlogSettings.Instance.FileExtension", "BlogConfig.FileExtension");
                    ReplaceInFile(filePath, "\"login.aspx", "\"account/login.aspx");
                }

                installedFiles.Add(fileToCopy);
            }
        }