Since WinRT exposes both the IStorageFolder
interface and the StorageFolder
class, my reflex was to use the interface throughout my code. I reasoned that IStorageFolder
could be used as an abstraction to support non-filesystem folders like those in compressed archives. However, looking at the IStorageFolder
interface, every method is declared to return concrete StorageFolder
instances. As such, it would not be possible to implement a virtual filesystem based on this interface.
So how is IStorageFolder
a useful abstraction? Or does its existence have a technical justification?
It is an interface because there are two implementations of IStorageFolder
: One is StorageFolder
, and another is FolderInformation
. Since there are two implementations, the common behavior uses an interface so that you can write a function that operates on either StorageFolder
or FolderInformation
.