Example #1
0
        public static async Task <bool> CopyAzureResourceToPackageAsync(
            ContentURI uri, string rootDirectory, string newDirectory,
            string parentFileName, IDictionary <string, string> zipArgs, string baseResourceFullURI)
        {
            bool   bHasCopied     = false;
            string sPackageNewURI = string.Empty;

            if (!string.IsNullOrEmpty(baseResourceFullURI))
            {
                //get the filename
                string sFileName = Path.GetFileName(baseResourceFullURI);
                sPackageNewURI = string.Concat(Path.Combine(newDirectory,
                                                            uri.URIDataManager.ResourceURIName),
                                               GeneralHelpers.FILE_PATH_DELIMITER,
                                               sFileName);
                Helpers.FileStorageIO.DirectoryCreate(uri, sPackageNewURI);
                //don't add the same file to the zip args (or the string array becomes out of synch)
                if (await Helpers.FileStorageIO.URIAbsoluteExists(uri, sPackageNewURI) == false)
                {
                    AzureIOAsync azureIO      = new AzureIOAsync(uri);
                    string       sBlobURIPath = string.Empty;
                    await azureIO.SaveCloudFileInFileSystemAsync(baseResourceFullURI,
                                                                 sPackageNewURI);

                    azureIO = null;
                    //parentFileNameKey tells package how to relate resource to parentfile
                    if (!zipArgs.ContainsKey(sPackageNewURI))
                    {
                        zipArgs.Add(sPackageNewURI, parentFileName);
                    }
                }
            }
            return(bHasCopied);
        }