简体   繁体   English

找不到sqlite文件,不确定c#在做什么

[英]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. 我尝试搜索所有.db文件,但该文件不存在。 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. 因此,这是我用于创建数据库的代码,因为如果您尝试打开连接并且文件不存在,则sqlite将创建数据库。 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 Ands我创建数据库

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? 如果我在调试模式下工作,则它位于bin / debug文件中,但是在我安装它时,它在哪里呢?

Ty all kindly in advance for any help 提前请大家帮忙

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. 我终于在配置文件的AppData\\Local\\VirtualStore文件夹中找到了我的数据库文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM