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


C# StorageFile.OpenTransactedWriteAsync方法代码示例

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


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

示例1: SaveToFileAsync

        private async void SaveToFileAsync(StorageFile f, string content)
        {
            try
            {
                using (StorageStreamTransaction transaction = await f.OpenTransactedWriteAsync())
                {

                    using (DataWriter dataWriter = new DataWriter(transaction.Stream))
                    {
                        dataWriter.WriteString(content);
                        transaction.Stream.Size = await dataWriter.StoreAsync(); // reset stream size to override the file
                        await transaction.CommitAsync();
                    }
                }
            }
            catch (Exception ex)
            {
                AddLog("AddToFileAsync Error: " + ex.Message);
            }
        }
开发者ID:CQE,项目名称:AOU-Manager-DataHandler,代码行数:20,代码来源:TextFile.cs

示例2: DownloadToFileAsync

        public IAsyncOperation<bool> DownloadToFileAsync(IRecord record, StorageFile file)
        {
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }

            return AsyncInfo.Run(cancelToken => Task.Run(async () =>
                {
                    using (
                        StorageStreamTransaction transaction =
                            await file.OpenTransactedWriteAsync().AsTask(cancelToken))
                    {
                        return await DownloadAsync(record, transaction.Stream).AsTask(cancelToken);
                    }
                }));
        }
开发者ID:CHBase,项目名称:chbase-windows8-sdk,代码行数:17,代码来源:PersonalImage.cs

示例3: writeXmlAsync

 public static async Task writeXmlAsync(object value, StorageFile file)
 {
     if (file != null) {
         using (var transaction = await file.OpenTransactedWriteAsync()) {
             using (var writer = new DataWriter(transaction.Stream)) {
                 writer.WriteString(writeXml(value));
                 transaction.Stream.Size = await writer.StoreAsync();
                 await transaction.CommitAsync();
             }
         }
     }
 }
开发者ID:jijixi,项目名称:PlistCS,代码行数:12,代码来源:Plist.cs

示例4: DownloadToFileAsync

        public IAsyncAction DownloadToFileAsync(StorageFile target, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext)
        {
            CommonUtility.AssertNotNull("target", target);

            return AsyncInfo.Run(async (token) =>
            {
                using (StorageStreamTransaction transaction = await target.OpenTransactedWriteAsync().AsTask(token))
                {
                    await this.DownloadToStreamAsync(transaction.Stream, accessCondition, options, operationContext).AsTask(token);
                    await transaction.CommitAsync();
                }
            });
        }
开发者ID:DaC24,项目名称:azure-storage-net,代码行数:13,代码来源:CloudFile.cs

示例5: DownloadToFileAsync

 public virtual Task DownloadToFileAsync(StorageFile target, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
 {
     return Task.Run(async () =>
     {
         using (StorageStreamTransaction transaction = await target.OpenTransactedWriteAsync().AsTask(cancellationToken))
         {
             await this.DownloadToStreamAsync(transaction.Stream.AsStream(), accessCondition, options, operationContext, cancellationToken);
             await transaction.CommitAsync();
         }
     });
 }
开发者ID:tamram,项目名称:azure-storage-net,代码行数:11,代码来源:CloudBlob.cs

示例6: file_serialization

        private async void file_serialization(StorageFile temp, string str)
        {
            int n;
            if (temp.Name != "README.md")
            {
                str = "#" + title + "\n\n" + str;
            }

            n = str.IndexOf(advertisement);
            if (n < 0)
            {
                str += advertisement;
            }

            //title
            //str = "#" + title + "\n" + str;
            str = str.Replace("\n", "\n\n");
            str = str.Replace("\n\n\n\n", "\n\n");
            str = str.Replace("\n", "\r\n");
            //StorageFile temp = _file_storage.file;
            if (temp != null)
            {
                using (StorageStreamTransaction transaction = await temp.OpenTransactedWriteAsync())
                {
                    using (DataWriter data_writer = new DataWriter(transaction.Stream))
                    {
                        data_writer.WriteString(str);
                        transaction.Stream.Size = await data_writer.StoreAsync();
                        await transaction.CommitAsync();
                    }
                }
            }
        }
开发者ID:lindexi,项目名称:Markdown,代码行数:33,代码来源:winmain.cs

示例7: SaveFile

        public async void SaveFile()
        {
            if (Saved)
            {
                return;
            }
            var fileBuffer = await Response.Content.ReadAsBufferAsync();
            int dotIndex = FullName.LastIndexOf('.');
            var extName = FullName.Substring(dotIndex);
            var savePicker = new Windows.Storage.Pickers.FileSavePicker();
            savePicker.SuggestedStartLocation =
                Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
            savePicker.FileTypeChoices.Add(new KeyValuePair<string, IList<string>>("file", new List<string> { extName }));

            savePicker.SuggestedFileName = FullName;

            LocalStorage = await savePicker.PickSaveFileAsync();
            var writeStream = await LocalStorage.OpenTransactedWriteAsync();
            await writeStream.Stream.WriteAsync(fileBuffer);
            await writeStream.CommitAsync();
            Saved = true;
        }
开发者ID:poiiii,项目名称:QBox-1,代码行数:22,代码来源:Files.cs


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