在WinRT中,没有FileInfo
类,只有StorageFile
类。
如何使用StorageFile
类获取文件大小?
答案 0 :(得分:11)
在C#中:
StorageFile file = await openPicker.PickSingleFileAsync();
BasicProperties pro = await file.GetBasicPropertiesAsync();
if (pro.Size != 0){}
您应该使用Windows.Storage.FileProperties for BasicProperties。
答案 1 :(得分:10)
所以你走了:
storageFile.getBasicPropertiesAsync().then(
function (basicProperties) {
var size = basicProperties.size;
}
);
答案 2 :(得分:0)
你试过这个:
create_task(file->GetBasicPropertiesAsync()).then([this, file](BasicProperties^ basicProperties) { String^ dateModifiedString = dateFormat->Format(basicProperties->DateModified) + " " + timeFormat->Format(basicProperties->DateModified); OutputTextBlock->Text += "\nFile size: " + basicProperties->Size.ToString() + " bytes" + "\nDate modified: " + dateModifiedString; });