Пример #1
0
        public static async Task <bool> CopyRelatedDataToWebServerPackageAsync(
            ContentURI uri, string currentFilePath,
            string packageName, string fileType, string newFilePath,
            bool needsAllRelatedData, IDictionary <string, string> zipArgs)
        {
            bool          bHasCopied = false;
            DirectoryInfo oldDir     = null;

            if (Path.HasExtension(currentFilePath))
            {
                //if it has an extension it needs the parent directory
                oldDir = new DirectoryInfo(
                    Path.GetDirectoryName(currentFilePath));
            }
            else
            {
                oldDir = new DirectoryInfo(currentFilePath);
            }
            DirectoryInfo newDir = null;

            if (Path.HasExtension(newFilePath))
            {
                //if it has an extension it needs the parent directory
                newDir = new DirectoryInfo(
                    Path.GetDirectoryName(newFilePath));
            }
            else
            {
                newDir = new DirectoryInfo(newFilePath);
            }
            //add siblings for everything
            bHasCopied = await AddSiblingFilesAsync(
                uri, oldDir, currentFilePath, packageName,
                fileType, newDir.FullName, zipArgs);

            if (needsAllRelatedData)
            {
                //copy children subfolder data
                //html subdirectories get put in root path so they can find resources
                bool bNeedsNewSubDirectories =
                    (fileType.EndsWith(AppHelpers.Resources.FILEEXTENSION_TYPES.xml.ToString()))
                    ? true : false;
                bool bHasCopiedDirs
                    = await GeneralHelpers.CopyDirectoriesAsync(
                          uri, currentFilePath,
                          newFilePath, bNeedsNewSubDirectories);

                //add them to zipargs
                bool bHasAdded = await AddChildrenFilesToZipArgsAsync(newDir, packageName, fileType, zipArgs);
            }
            return(bHasCopied);
        }