【问题标题】:How to get file size in WinRT?如何在 WinRT 中获取文件大小?
【发布时间】:2013-01-05 03:59:29
【问题描述】:

在 WinRT 中没有 FileInfo 类,只有 StorageFile 类。

如何使用StorageFile 类获取文件的大小?

【问题讨论】:

    标签: c# filesize winrt-async


    【解决方案1】:

    所以你去:

    
    storageFile.getBasicPropertiesAsync().then(
        function (basicProperties) {
            var size  = basicProperties.size;
        }
    );
    

    【讨论】:

    • GetBasicPropertiesAsync 上的大写 G 的价值。
    【解决方案2】:

    在 C# 中:

    StorageFile file = await openPicker.PickSingleFileAsync();
    BasicProperties pro = await file.GetBasicPropertiesAsync();
    if (pro.Size != 0){}
    

    您应该将 Windows.Storage.FileProperties 用于 BasicProperties。

    【讨论】:

      【解决方案3】:

      你试过了吗:

      create_task(file->GetBasicPropertiesAsync()).then([this, file](BasicProperties^ basicProperties) { String^ dateModifiedString = dateFormat->Format(basicProperties->DateModified) + " " + timeFormat->Format(basicProperties->DateModified); OutputTextBlock->Text += "\n文件大小:" + basicProperties->Size.ToString() + " bytes" + "\n修改日期:" + dateModifiedString; });

      见: http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.fileproperties.basicproperties.size.aspx

      【讨论】:

      • 他需要c# 中的答案,而不是 C++
      • :)) 终于成功了!我在这里很新:D
      猜你喜欢
      • 2014-04-10
      • 1970-01-01
      • 1970-01-01
      • 2010-11-25
      • 2011-08-22
      • 1970-01-01
      • 2023-01-11
      • 2012-02-24
      相关资源
      最近更新 更多