win-universal-appdesktop-bridge

Migrating a Win32 app that uses the AppData folder to share files to Desktop Bridge


I am migrating some Win32 apps to the Windows Store using Desktop Bridge. I have several apps that have been sharing files in %APPDATA%\Roaming\XYZCompany. I understand from the Microsoft docs that this will no longer work since each app will have its own isolated version of the AppData folder.

So what is the "right" way to share files between my own UWP / Desktop Bridge apps?

The best solution I've come up with so far is moving the shared files to the user's documents folder, but that seems ugly. In iOS and Android there are slick ways for apps from one developer to share files. Is there something like that for UWP apps that I just haven't found?


Solution

  • You can create a PublisherCacheFolder (see documentation) which can be used to share data among your UWP apps.

    To be able to use this API, you need to declare the names of your folder in the package.appxmanifest file:

    <Extensions>    
        <Extension Category="windows.publisherCacheFolders"> 
         <PublisherCacheFolders>
           <Folder Name="MyFolder" />
         </PublisherCacheFolders>    
        </Extension>  
    </Extensions>
    

    Now you can access this folder:

    var folder = ApplicationData.Current.GetPublisherCacheFolder( "MyFolder" );
    

    For more info look into this article on MSDN.