Why does a MAUI app store data under “User Name” on Windows?

I am experimenting with Microsoft’s MAUI (multi-platform app UI) and have encountered various little problems. MAUI apps run on Android, iOS, Windows (WinUI 3) and Mac (Mac Catalyst), though in my case I am mainly interested in Windows and Mac.

The application needs local storage and follows the mobile app principle of isolating this into a directory largely buried from the user’s view. On the Mac this location is:

/Users/[username]/Library/Containers/[ApplicationId]/

where the [username] is my username on the Mac, and the [ApplicationId] is the App Identifier set in the .csproj project configuration file. All this makes sense to me.

On Windows though I was surprised to see that the local storage was at:

c:\Users\[username]\AppData\Local\User Name

Note that “User Name” is the actual name of the directory, not a placeholder for my username.

I thought this must be a bug and even looked at the MAUI source on GitHub. It turns out that it is not a bug; it is the default value for PublisherDisplayName in the platform-specific file Package.appxmanifest. I replaced this with something more suitable and this then became the name of the directory.

The application data is in a subfolder, the name of which is determined by the DisplayName of the application. For a packaged application installed from the Microsoft Store, publishers register this name with Microsoft to avoid conflict with another publisher.