Sqlite中如何使用通配符匹配目录路径

How to use wildcards to match directory paths in Sqlite

我有一个包含文件夹路径的数据库,我想找到某个文件夹包含的所有文件夹。我得到部分结果:

select * from pathTable where Path like ?||'%'

给出

c:\root\1
c:\root\1 Copy
c:\root\1\2
c:\root\1\3\3a
c:\root\1\4

什么时候?是"c:\root\1",上面查询returns

c:\root\1
c:\root\1 Copy

我也想获取所有子文件夹。我怀疑 Sqlite 在存储路径中遇到了“\”。有人知道我做错了什么吗?

这是我必须执行的操作,以允许通过 @ 符号 "fully" 转义字符串参数。

void printPaths()
    {
        string mypath = @"c:\root\1";
        string sql = ("select * from paths where pathdesc like @mypath");

        SQLiteCommand command = new SQLiteCommand(sql,m_dbConnection);
        command.Parameters.AddWithValue("@mypath", mypath+"%");

        SQLiteDataReader reader = command.ExecuteReader();
        while (reader.Read())
            Console.WriteLine("ID: " + reader["pathid"] + "\tpathdesc: " + reader["pathdesc"]);
        Console.ReadLine();
    }