Popular Posts
Blog Archive
Stats
Query index data
1. Start window service Indexing Service
2. Create a new category and start indexing.
class Program
{
    static void Main(string[] args)
    {
        // reference : http://msdn.microsoft.com/en-us/library/ms690516
        string strCatalog = "TestIndexing";
        string strKeyword = "readme";  // search keyword
        string strQuery = string.Format(
            @"SELECT path, FileName, size, write, attrib FROM SCOPE() WHERE FREETEXT('{0}')",
            //@"SELECT * FROM FILEINFO WHERE FREETEXT('{0}')",
            strKeyword
        );
 
        string connstring = "Provider=MSIDXS.1;Integrated Security .='';Data Source=" + strCatalog;
 
        DataSet set = null;
        try
        {
            using (OleDbDataAdapter adapter = new OleDbDataAdapter(strQuery, connstring))
            {
                adapter.Fill(set = new DataSet());
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            return;
        }
 
        foreach (DataRow row in set.Tables[0].Rows)
        {
            Console.WriteLine("{0} |{1} @{2}", row["FileName"], row["size"], row["write"]);
        }
        Console.Read();
    }
}