maui-file-handling
Installation
SKILL.md
.NET MAUI File Handling
Critical: Always Use OpenReadAsync(), Not FullPath
Some platforms (especially Android) return content URIs, not file system
paths. Reading FullPath directly will throw or return empty data.
// ❌ Breaks on Android — FullPath may be a content:// URI
var result = await FilePicker.Default.PickAsync();
var bytes = File.ReadAllBytes(result.FullPath);
// ✅ Works on all platforms
var result = await FilePicker.Default.PickAsync();
if (result is not null)
{
using var stream = await result.OpenReadAsync();
// process stream
}
Related skills