当前位置: 首页>>代码示例>>C#>>正文


C# ICloudBlob.BeginDownloadToStream方法代码示例

本文整理汇总了C#中ICloudBlob.BeginDownloadToStream方法的典型用法代码示例。如果您正苦于以下问题:C# ICloudBlob.BeginDownloadToStream方法的具体用法?C# ICloudBlob.BeginDownloadToStream怎么用?C# ICloudBlob.BeginDownloadToStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICloudBlob的用法示例。


在下文中一共展示了ICloudBlob.BeginDownloadToStream方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DownloadTextAPM

 public static string DownloadTextAPM(ICloudBlob blob, Encoding encoding, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null)
 {
     using (MemoryStream stream = new MemoryStream())
     {
         using (AutoResetEvent waitHandle = new AutoResetEvent(false))
         {
             IAsyncResult result = blob.BeginDownloadToStream(stream, accessCondition, options, operationContext, ar => waitHandle.Set(), null);
             waitHandle.WaitOne();
             blob.EndDownloadToStream(result);
             return encoding.GetString(stream.ToArray());
         }
     }
 }
开发者ID:huoxudong125,项目名称:azure-sdk-for-net,代码行数:13,代码来源:BlobTestBase.cs

示例2: DownloadBlobAsync

        public void DownloadBlobAsync(ICloudBlob blob, string LocalFile)
        {
            // The class currently stores state in class level variables so calling UploadBlobAsync or DownloadBlobAsync a second time will cause problems.
            // A better long term solution would be to better encapsulate the state, but the current solution works for the needs of my primary client.
            // Throw an exception if UploadBlobAsync or DownloadBlobAsync has already been called.
            lock (WorkingLock)
            {
                if (!Working)
                    Working = true;
                else
                    throw new Exception("BlobTransfer already initiated. Create new BlobTransfer object to initiate a new file transfer.");
            }

            // Create an async op in order to raise the events back to the client on the correct thread.
            asyncOp = AsyncOperationManager.CreateOperation(blob);

            TransferType = TransferTypeEnum.Download;
            m_Blob = blob;
            m_FileName = LocalFile;

            m_Blob.FetchAttributes();

            FileStream fs = new FileStream(m_FileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read);
            ProgressStream pstream = new ProgressStream(fs);
            pstream.ProgressChanged += pstream_ProgressChanged;
            pstream.SetLength(m_Blob.Properties.Length);
            m_Blob.ServiceClient.ParallelOperationThreadCount = 10;
            asyncresult = m_Blob.BeginDownloadToStream(pstream, BlobTransferCompletedCallback, new BlobTransferAsyncState(m_Blob, pstream));
        }
开发者ID:jdupler714,项目名称:TyrosLayout,代码行数:29,代码来源:BlobTransferHelper.cs


注:本文中的ICloudBlob.BeginDownloadToStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。