[英]How to get file size in WinRT?
在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 for BasicProperties。
你试过这个:
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; });
请参阅: http : //msdn.microsoft.com/en-us/library/windows/apps/windows.storage.fileproperties.basicproperties.size.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.