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


C# File.CloudFile类代码示例

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


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


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