8

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

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

4

3 回答 3

12

所以你去:


storageFile.getBasicPropertiesAsync().then(
    function (basicProperties) {
        var size  = basicProperties.size;
    }
);
于 2013-01-05T04:09:17.040 回答
11

在 C# 中:

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

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

于 2013-08-21T04:12:48.087 回答
0

你有没有试过这个:

        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

于 2013-01-05T04:02:34.370 回答