• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# File.CloudFile类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.WindowsAzure.Storage.File.CloudFile的典型用法代码示例。如果您正苦于以下问题:C# CloudFile类的具体用法?C# CloudFile怎么用?C# CloudFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CloudFile类属于Microsoft.WindowsAzure.Storage.File命名空间,在下文中一共展示了CloudFile类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CloudFileWriter

 internal CloudFileWriter(
     TransferScheduler scheduler,
     SyncTransferController controller,
     CancellationToken cancellationToken)
     : base(scheduler, controller, cancellationToken)
 {
     this.cloudFile = this.TransferJob.Destination.AzureFile;
 }
开发者ID:BeauGesteMark,项目名称:azure-storage-net-data-movement,代码行数:8,代码来源:CloudFileWriter.cs


示例2: DownloadTextAsync

 public static async Task<string> DownloadTextAsync(CloudFile file, Encoding encoding, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null)
 {
     using (MemoryStream stream = new MemoryStream())
     {
         await file.DownloadToStreamAsync(stream, accessCondition, options, operationContext);
         return encoding.GetString(stream.ToArray(), 0, (int)stream.Length);
     }
 }
开发者ID:tamram,项目名称:azure-storage-net,代码行数:8,代码来源:FileTestBase.cs


示例3: AzureFileLocation

        /// <summary>
        /// Initializes a new instance of the <see cref="AzureFileLocation"/> class.
        /// </summary>
        /// <param name="azureFile">CloudFile instance as a location in a transfer job. 
        /// It could be a source, a destination.</param>
        public AzureFileLocation(CloudFile azureFile)
        { 
            if (null == azureFile)
            {
                throw new ArgumentNullException("azureFile");
            }

            this.AzureFile = azureFile;
        }
开发者ID:ggais,项目名称:azure-storage-net-data-movement,代码行数:14,代码来源:AzureFileLocation.cs


示例4: CloudFileReader

 public CloudFileReader(
     TransferScheduler scheduler,
     SyncTransferController controller,
     CancellationToken cancellationToken)
     :base(scheduler, controller, cancellationToken)
 {
     this.file = this.SharedTransferData.TransferJob.Source.AzureFile;
     Debug.Assert(null != this.file, "Initializing a CloudFileReader, the source location should be a CloudFile instance.");
 }
开发者ID:BeauGesteMark,项目名称:azure-storage-net-data-movement,代码行数:9,代码来源:CloudFileReader.cs


示例5: WaitForCopyAsync

 public static async Task WaitForCopyAsync(CloudFile file)
 {
     bool copyInProgress = true;
     while (copyInProgress)
     {
         await Task.Delay(1000);
         await file.FetchAttributesAsync();
         copyInProgress = (file.CopyState.Status == CopyStatus.Pending);
     }
 }
开发者ID:tamram,项目名称:azure-storage-net,代码行数:10,代码来源:FileTestBase.cs


示例6: WaitForCopyTask

 public static void WaitForCopyTask(CloudFile file)
 {
     bool copyInProgress = true;
     while (copyInProgress)
     {
         Thread.Sleep(1000);
         file.FetchAttributesAsync().Wait();
         copyInProgress = (file.CopyState.Status == CopyStatus.Pending);
     }
 }
开发者ID:benaadams,项目名称:azure-storage-net,代码行数:10,代码来源:FileTestBase.cs


示例7: UploadTextAsync

 public static async Task UploadTextAsync(CloudFile file, string text, Encoding encoding, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null)
 {
     byte[] textAsBytes = encoding.GetBytes(text);
     using (MemoryStream stream = new MemoryStream())
     {
         stream.Write(textAsBytes, 0, textAsBytes.Length);
         stream.Seek(0, SeekOrigin.Begin);
         file.ServiceClient.DefaultRequestOptions.ParallelOperationThreadCount = 2;
         await file.UploadFromStreamAsync(stream, accessCondition, options, operationContext);
     }
 }
开发者ID:tamram,项目名称:azure-storage-net,代码行数:11,代码来源:FileTestBase.cs


示例8: AssertAreEqual

 public static void AssertAreEqual(CloudFile expected, CloudFile actual)
 {
     if (expected == null)
     {
         Assert.IsNull(actual);
     }
     else
     {
         Assert.IsNotNull(actual);
         Assert.AreEqual(expected.Uri, actual.Uri);
         Assert.AreEqual(expected.StorageUri, actual.StorageUri);
         AssertAreEqual(expected.Properties, actual.Properties);
     }
 }
开发者ID:Gajendra-Bahakar,项目名称:azure-storage-net,代码行数:14,代码来源:FileTestBase.Common.cs


示例9: StopCopyFile

        /// <summary>
        /// Stop copy operation by CloudBlob object
        /// </summary>
        /// <param name="blob">CloudBlob object</param>
        /// <param name="copyId">Copy id</param>
        private async Task StopCopyFile(long taskId, IStorageFileManagement localChannel, CloudFile file, string copyId)
        {
            FileRequestOptions requestOptions = RequestOptions;

            //Set no retry to resolve the 409 conflict exception
            requestOptions.RetryPolicy = new NoRetry();

            string abortCopyId = string.Empty;

            if (string.IsNullOrEmpty(copyId) || Force)
            {
                //Make sure we use the correct copy id to abort
                //Use default retry policy for FetchBlobAttributes
                FileRequestOptions options = RequestOptions;
                await localChannel.FetchFileAttributesAsync(file, null, options, OperationContext, CmdletCancellationToken);

                if (file.CopyState == null || string.IsNullOrEmpty(file.CopyState.CopyId))
                {
                    ArgumentException e = new ArgumentException(String.Format(Resources.FileCopyTaskNotFound, file.Uri.ToString()));
                    OutputStream.WriteError(taskId, e);
                }
                else
                {
                    abortCopyId = file.CopyState.CopyId;
                }

                if (!Force)
                {
                    string confirmation = String.Format(Resources.ConfirmAbortFileCopyOperation, file.Uri.ToString(), abortCopyId);
                    if (!await OutputStream.ConfirmAsync(confirmation))
                    {
                        string cancelMessage = String.Format(Resources.StopCopyOperationCancelled, file.Uri.ToString());
                        OutputStream.WriteVerbose(taskId, cancelMessage);
                    }
                }
            }
            else
            {
                abortCopyId = copyId;
            }

            await localChannel.AbortCopyAsync(file, abortCopyId, null, requestOptions, OperationContext, CmdletCancellationToken);
            string message = String.Format(Resources.StopCopyFileSuccessfully, file.Uri.ToString());
            OutputStream.WriteObject(taskId, message);
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:50,代码来源:StopAzureStorageFileCopy.cs


示例10: FileReadStreamBase

        /// <summary>
        /// Initializes a new instance of the <see cref="FileReadStreamBase"/> class.
        /// </summary>
        /// <param name="file">File reference to read from</param>
        /// <param name="accessCondition">An <see cref="AccessCondition"/> object that represents the access conditions for the file. If <c>null</c>, no condition is used.</param>
        /// <param name="options">An <see cref="FileRequestOptions"/> object that specifies additional options for the request.</param>
        /// <param name="operationContext">An <see cref="OperationContext"/> object for tracking the current operation.</param>
        protected FileReadStreamBase(CloudFile file, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext)
        {
            if (options.UseTransactionalMD5.Value)
            {
                CommonUtility.AssertInBounds("StreamMinimumReadSizeInBytes", file.StreamMinimumReadSizeInBytes, 1, Constants.MaxRangeGetContentMD5Size);
            }

            this.file = file;
            this.fileProperties = new FileProperties(file.Properties);
            this.currentOffset = 0;
            this.streamMinimumReadSizeInBytes = this.file.StreamMinimumReadSizeInBytes;
            this.internalBuffer = new MultiBufferMemoryStream(file.ServiceClient.BufferManager);
            this.accessCondition = accessCondition;
            this.options = options;
            this.operationContext = operationContext;
            this.fileMD5 = (this.options.DisableContentMD5Validation.Value || string.IsNullOrEmpty(this.fileProperties.ContentMD5)) ? null : new MD5Wrapper();
            this.lastException = null;
        }
开发者ID:Gajendra-Bahakar,项目名称:azure-storage-net,代码行数:25,代码来源:FileReadStreamBase.cs


示例11: SetFile

        internal static void SetFile(ref SerializableCloudFile fileSerialization, CloudFile value)
        {
            if (null == fileSerialization
                && null == value)
            {
                return;
            }

            if (null != fileSerialization)
            {
                fileSerialization.File = value;
            }
            else
            {
                fileSerialization = new SerializableCloudFile()
                {
                    File = value
                };
            }
        }
开发者ID:BeauGesteMark,项目名称:azure-storage-net-data-movement,代码行数:20,代码来源:SerializableCloudFile.cs


示例12: FileWriteStreamBase

 /// <summary>
 /// Initializes a new instance of the FileWriteStreamBase class for a file.
 /// </summary>
 /// <param name="file">File reference to write to.</param>
 /// <param name="fileSize">Size of the file.</param>
 /// <param name="createNew">Use <c>true</c> if the file is newly created, <c>false</c> otherwise.</param>
 /// <param name="accessCondition">An <see cref="AccessCondition"/> object that represents the access conditions for the file. If <c>null</c>, no condition is used.</param>
 /// <param name="options">An <see cref="FileRequestOptions"/> object that specifies additional options for the request.</param>
 /// <param name="operationContext">An <see cref="OperationContext"/> object for tracking the current operation.</param>
 protected FileWriteStreamBase(CloudFile file, long fileSize, bool createNew, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext)
     : base()
 {
     this.internalBuffer = new MultiBufferMemoryStream(file.ServiceClient.BufferManager);
     this.currentOffset = 0;
     this.accessCondition = accessCondition;
     this.options = options;
     this.operationContext = operationContext;
     this.noPendingWritesEvent = new CounterEvent();
     this.fileMD5 = this.options.StoreFileContentMD5.Value ? new MD5Wrapper() : null;
     this.rangeMD5 = this.options.UseTransactionalMD5.Value ? new MD5Wrapper() : null;
     this.parallelOperationSemaphore = new AsyncSemaphore(options.ParallelOperationThreadCount.Value);
     this.lastException = null;
     this.committed = false;
     this.disposed = false;
     this.currentFileOffset = 0;
     this.file = file;
     this.fileSize = fileSize;
     this.streamWriteSizeInBytes = file.StreamWriteSizeInBytes;
     this.newFile = createNew;
 }
开发者ID:benaadams,项目名称:azure-storage-net,代码行数:30,代码来源:FileWriteStreamBase.cs


示例13: GetFileSASToken

        private static string GetFileSASToken(CloudFile file)
        {
            if (null == file.ServiceClient.Credentials
                || file.ServiceClient.Credentials.IsAnonymous)
            {
                return string.Empty;
            }
            else if (file.ServiceClient.Credentials.IsSAS)
            {
                return file.ServiceClient.Credentials.SASToken;
            }

            // SAS life time is at least 10 minutes.
            TimeSpan sasLifeTime = TimeSpan.FromMinutes(CopySASLifeTimeInMinutes);

            SharedAccessFilePolicy policy = new SharedAccessFilePolicy()
            {
                SharedAccessExpiryTime = DateTime.Now.Add(sasLifeTime),
                Permissions = SharedAccessFilePermissions.Read,
            };

            return file.GetSharedAccessSignature(policy);
        }
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:23,代码来源:StorageExtensions.cs


示例14: StartCopyAsync

 public virtual Task<string> StartCopyAsync(CloudFile source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext)
 {
     return this.StartCopyAsync(source, sourceAccessCondition, destAccessCondition, options, operationContext, CancellationToken.None);
 }
开发者ID:tamram,项目名称:azure-storage-net,代码行数:4,代码来源:CloudBlockBlob.cs


示例15: BeginStartCopy

 public virtual ICancellableAsyncResult BeginStartCopy(CloudFile source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state)
 {
     return this.BeginStartCopy(CloudFile.SourceFileToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext, callback, state);
 }
开发者ID:tamram,项目名称:azure-storage-net,代码行数:4,代码来源:CloudBlockBlob.cs


示例16: StartCopy

 public virtual string StartCopy(CloudFile source, AccessCondition sourceAccessCondition = null, AccessCondition destAccessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null)
 {
     return this.StartCopy(CloudFile.SourceFileToUri(source), sourceAccessCondition, destAccessCondition, options, operationContext);
 }
开发者ID:tamram,项目名称:azure-storage-net,代码行数:4,代码来源:CloudBlockBlob.cs


示例17: FileWriteStream

 /// <summary>
 /// Initializes a new instance of the FileWriteStream class for a file.
 /// </summary>
 /// <param name="file">File reference to write to.</param>
 /// <param name="fileSize">Size of the file.</param>
 /// <param name="createNew">Use <c>true</c> if the file is newly created, <c>false</c> otherwise.</param>
 /// <param name="accessCondition">An <see cref="AccessCondition"/> object that represents the access conditions for the file. If <c>null</c>, no condition is used.</param>
 /// <param name="options">An <see cref="FileRequestOptions"/> object that specifies additional options for the request.</param>
 /// <param name="operationContext">An <see cref="OperationContext"/> object for tracking the current operation.</param>
 internal FileWriteStream(CloudFile file, long fileSize, bool createNew, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext)
     : base(file, fileSize, createNew, accessCondition, options, operationContext)
 {
 }
开发者ID:vinaysh-msft,项目名称:azure-storage-net,代码行数:13,代码来源:FileWriteStream.cs


示例18: FileExistsAsync

 public Task<bool> FileExistsAsync(CloudFile file, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
 {
     return file.ExistsAsync(options, operationContext, cancellationToken);
 }
开发者ID:NordPool,项目名称:azure-sdk-tools,代码行数:4,代码来源:StorageFileManagement.cs


示例19: FileExistsAsync

 public Task<bool> FileExistsAsync(CloudFile file, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
 {
     return TaskEx.FromResult(true);
 }
开发者ID:Indhukrishna,项目名称:azure-powershell,代码行数:4,代码来源:MockStorageFileManagement.cs


示例20: FileReadStream

 /// <summary>
 /// Initializes a new instance of the <see cref="FileReadStream"/> class.
 /// </summary>
 /// <param name="file">File reference to read from.</param>
 /// <param name="accessCondition">An object that represents the access conditions for the file. If null, no condition is used.</param>
 /// <param name="options">An object that specifies additional options for the request.</param>
 /// <param name="operationContext">An <see cref="OperationContext"/> object that represents the context for the current operation.</param>
 internal FileReadStream(CloudFile file, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext)
     : base(file, accessCondition, options, operationContext)
 {
 }
开发者ID:mirobers,项目名称:azure-storage-net,代码行数:11,代码来源:FileReadStream.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Queue.CloudQueue类代码示例发布时间:2022-05-26
下一篇:
C# Core.UriQueryBuilder类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap