【问题标题】:Roamingfolder.CreateFileAsync how do I close the fileRoamingfolder.CreateFileAsync 如何关闭文件
【发布时间】:2012-12-23 10:32:38
【问题描述】:

使用此代码:

    private async void writeToStorage(string contents)
    {
        var roamingFolder = Windows.Storage.ApplicationData.Current.RoamingFolder;
        var storFile = await roamingFolder.CreateFileAsync("test", CreationCollisionOption.ReplaceExisting);

        await Windows.Storage.FileIO.WriteTextAsync(storFile, contents);
    }

我需要关闭文件吗?如果是这样..我该怎么做? storFile 上没有 Close。

【问题讨论】:

    标签: windows-8 microsoft-metro windows-runtime windows-store-apps


    【解决方案1】:

    不,您不需要关闭此文件。

    StorageFolderStorageFile 实例只是指向文件夹和文件的指针。 使用WriteTextAsync 方法将自动打开/写入和关闭流。

    【讨论】:

      猜你喜欢
      • 2014-05-01
      • 2016-12-03
      • 2016-01-19
      • 2015-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-14
      相关资源
      最近更新 更多