Why are Multiple Locations for .NET Maui programs used for SQLite db storage

Fritz Switzer 261 Reputation points

I am trying to find out the file location for my app's db. Using the same code, the db file is in two different locations for a .NET Maui Windows app.



Here is the code I am using.

  // TODO Only do this when app first runs
        var assembly = IntrospectionExtensions.GetTypeInfo(typeof(App)).Assembly;
        using (Stream stream = assembly.GetManifestResourceStream("MauiApp3.chinook.db"))
            using (MemoryStream memoryStream = new MemoryStream())

                File.WriteAllBytes(EmployeeRepository.DbPath, memoryStream.ToArray());

  private readonly SQLiteConnection _database;

        public static string DbPath { get; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "chinook.db");

How do I know where the file will be stored?

I am using an existing db file that is "Embedded Resource" and Copy If Newer

A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,179 questions
{count} votes