ACR_ServerCommunicator.ModuleContentPatcher.DownloadContentPatchFromFileStore C# (CSharp) Method

DownloadContentPatchFromFileStore() private static method

Download a content patch file from a file store. Currently, Azure file stores are assumed. Both compressed and uncompressed versions of the file are tried in respective order.
private static DownloadContentPatchFromFileStore ( string FileStorePath, string LocalFileName, string ConnectionString, ACR_ServerCommunicator Script ) : void
FileStorePath string Supplies the remote file name that /// designates the file to download.
LocalFileName string Supplies the local file name to /// download to.
ConnectionString string Supplies the file store connection /// string.
Script ACR_ServerCommunicator Supplies the script object.
return void
        private static void DownloadContentPatchFromFileStore(string FileStorePath, string LocalFileName, string ConnectionString, ACR_ServerCommunicator Script)
        {
            if (String.IsNullOrEmpty(ConnectionString))
                throw new NotSupportedException();

            //
            // Initialize the file store provider.
            //

            FileStore UpdaterStore = FileStoreProvider.CreateAzureFileStore(ConnectionString);
            FileStoreContainer UpdaterContainer = UpdaterStore.GetContainerReference(FileStoreNamespace.ACRUpdater);
            FileStoreFile UpdaterFile = UpdaterContainer.GetFileReference(FileStorePath + ".gzip");

            //
            // First attempt to retrieve a gzip compressed version of the file
            // to patch.  If that fails then fall back to a plaintext version.
            //

            try
            {
                using (MemoryStream MemStream = new MemoryStream())
                {
                    UpdaterFile.Read(MemStream);

                    MemStream.Position = 0;

                    using (FileStream OutStream = File.Create(LocalFileName))
                    {
                        using (GZipStream CompressedStream = new GZipStream(MemStream, CompressionMode.Decompress))
                        {
                            CompressedStream.CopyTo(OutStream);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Script.WriteTimestampedLogEntry(String.Format("ModuleContentPatcher.DownloadContentPatchFromFileStore: Couldn't retrieve compressed file {0} from Azure, trying uncompressed file, due to exception: {1}",
                    FileStorePath,
                    e));

                UpdaterFile = UpdaterContainer.GetFileReference(FileStorePath);

                using (FileStream OutStream = File.Create(LocalFileName))
                {
                    UpdaterFile.Read(OutStream);
                }
            }
        }