dotnet / dotnet/runtime

System.Configuration files are saved in the app's Documents directory on iOS

Open
#120,892 7 comments 0 reactions 0 assignees View on GitHub
area-System.Runtime os-ios
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

### Description

When using [old dotnet settings](https://learn.microsoft.com/en-us/dotnet/desktop/winforms/advanced/application-settings-architecture) on iOS, the settings files are stored in the app container's "Documents" directory

`/var/mobile/Containers/Data/Application//Documents`

However, this location is intended for user-generated files (i.e. documents), not settings: https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html

In conjunction with `UISupportsDocumentBrowser`, the config files appear as documents accessible by all users in the iOS Files app.

### Reproduction Steps

Create a MAUI app and add a Settings file to it

Also configure the Info.plist to allow access to the Document folder:
```
UIFileSharingEnabled

UISupportsDocumentBrowser

```

### Expected behavior

Settings files should be saved to `/var/mobile/Containers/Data/Application//Library` (or some subdirectory)

### Actual behavior

Settings files are saved to `/var/mobile/Containers/Data/Application//Documents`

### Regression?

No

### Known Workarounds

_No response_

### Configuration

dotnet 9.0.306
iOS 26.0.1
ARM64

### Other information

I suspect the problem lies here:
https://github.com/dotnet/runtime/blob/ce9375b6a1770a6622829876723395b5e9948bc5/src/libraries/System.Configuration.ConfigurationManager/src/System/Configuration/ClientConfigPaths.cs#L162

`LocalApplicationData` resolves to the `Documents` directory on iOS, but I would expect it to resolve to the `Library` directory

Only the behavior for Catalyst appears to be documented:
https://learn.microsoft.com/en-us/dotnet/maui/macios/system-special-folders?view=net-maui-9.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.