Bear
Bear

Reputation: 516

can't find sqlite file, not sure what c# is doing

I have a program that works correctly and I can access the database from within the program... But my issue is this... The db is no where on my computer... at least where I can find it. I have tried searching for all .db files and it wasn't there. I want to be able to copy this file with an addition to my program that i am making, and back it up elsewhere. But I can't find it. I use an installer to install it correctly to program files under my name and that works too, the program runs and reads from the database. So here is the code I use to create the db since sqlite will create a db if you try to open a connection and a file doesn't exist. B

I check with

public void createDB()
    {
        string path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(sqlLib)).CodeBase);
        string[] brokenPath = path.Split('\\');
        path = "";
        for (int i = 1; i < brokenPath.Length; i++)//parse file name and rebuild to remove wrong chars
        {
            path += brokenPath[i];
            if (i < brokenPath.Length - 1)
                path += "\\";
        }

        MessageBox.Show(path);

        if (!File.Exists(path += "\\fman.db"))
        {
            MessageBox.Show("File doesn't exist");
            SQLiteConnection db = dbConnect();
            popDB(db);
            dbClose(db);
        }

Which again, works fine...

Ands I create the db with

static public SQLiteConnection dbConnect()
    {
        string ConnectString = "Data Source = fman.db;";
        SQLiteConnection db = new SQLiteConnection(ConnectString);
        db.Open();
        return db;
    }

So, I am able to access the db fine and read/write to the file but I can't find the file anywhere. If I work in debug mode it is right there in the bin/debug file, but when I install it, where is it going?

Ty all kindly in advance for any help

Upvotes: 1

Views: 2468

Answers (1)

parnellij
parnellij

Reputation: 21

This had me scratching my head for quite a while when it happened to me too.

I finally found my database file in the AppData\Local\VirtualStore folder in my profile.

Upvotes: 2

Related Questions