【发布时间】:2013-01-05 03:59:29
【问题描述】:
在 WinRT 中没有 FileInfo 类,只有 StorageFile 类。
如何使用StorageFile 类获取文件的大小?
【问题讨论】:
标签: c# filesize winrt-async
在 WinRT 中没有 FileInfo 类,只有 StorageFile 类。
如何使用StorageFile 类获取文件的大小?
【问题讨论】:
标签: c# filesize winrt-async
所以你去:
storageFile.getBasicPropertiesAsync().then(
function (basicProperties) {
var size = basicProperties.size;
}
);
【讨论】:
在 C# 中:
StorageFile file = await openPicker.PickSingleFileAsync();
BasicProperties pro = await file.GetBasicPropertiesAsync();
if (pro.Size != 0){}
您应该将 Windows.Storage.FileProperties 用于 BasicProperties。
【讨论】:
你试过了吗:
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; });【讨论】: