Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Windows 10 provides many techniques that developers can use for inter- app communications. Publisher Cache Folders is one such technique. The idea is that A publisher can have multiple applications in Windows Store and they may share common data , settings and other artifacts that could be leveraged across multiple applications.
While using Publisher Cache Folders in your application , here are few things to keep in mind
-The apps reading/writing or using Publisher Cache Folders needs to be from same publisher.
-Shared storage location is provisioned automatically when the first app for a given publisher is installed and it will be removed automatically when the last app for a given publisher is uninstalled
-You are responsible for data management /versioning inside the Publisher Cache Folder.
-Publisher Cache folder can also live in a SD card
Implementing Publisher Cache Folders is really easy. In following example I have implemented a simple read write on a text file that is living inside Publisher Cache Folders from 2 different applications.
As a first step we will declare the Publisher Cache Folder in the application manifest of each application wanting to use the folder.
<Extensions> <Extension Category="windows.publisherCacheFolders"> <PublisherCacheFolders > <Folder Name="CommonFolder"/> </PublisherCacheFolders> </Extension>
Now folder is available for us to be utilized from different applications. Writing to the folder from App1
async void WritetoPublisherFolder() { StorageFolder SharedFolder = Windows.Storage.ApplicationData.Current.GetPublisherCacheFolder("CommonFolder"); StorageFile newFile = await SharedFolder.CreateFileAsync("SharedFile.txt", CreationCollisionOption.OpenIfExists); await FileIO.WriteTextAsync(newFile, textBox.Text.ToString()); }
Reading from Folder from App2
async void ReadFromSharedFolder() { StorageFolder SharedFolder = Windows.Storage.ApplicationData.Current.GetPublisherCacheFolder("CommonFolder"); StorageFile newFile = await SharedFolder.GetFileAsync("SharedFile.txt"); var text= await FileIO.ReadTextAsync(newFile); textBlock.Text= await FileIO.ReadTextAsync(newFile); ; }
Publisher Cache Folders opens up many scenarios for the developers building multiple applications and sharing the data among those applications.
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in