Reputation: 91
How can i get value such as: LastAccesstime, LastWritetime, Length..v.v.. from Fileinfo fi ?
Upvotes: 0
Views: 180
Reputation: 29792
In UWP the most suitable way to access files is through StorageFiles rather than directly by path. In this case you may take a look at StorageFile.GetBasicPropertiesAsync() method:
foreach (StorageFile contentStream in pickedFile)
{
var prop = await contentStream.GetBasicPropertiesAsync();
DateTimeOffset lastModification = prop.DateModified;
DateTimeOffset itemTime = prop.ItemDate;
ulong size = prop.Size;
//...
}
The problem with FileInfo is that in most cases you don't have privilege to access file via its path, whereas StorageFile works like a broker and file open picker grants privilege.
Upvotes: 1