在 WinRT 中没有FileInfo
类,只有一个StorageFile
类。
如何使用StorageFile
类获取文件的大小?
所以你去:
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; });