Click here to Skip to main content
15,886,091 members
Home / Discussions / C#
   

C#

 
GeneralRe: Nested Query [modified] Pin
Tej Aj3-Mar-09 20:31
Tej Aj3-Mar-09 20:31 
GeneralRe: Nested Query Pin
Sajjad Leo3-Mar-09 20:43
Sajjad Leo3-Mar-09 20:43 
GeneralRe: Nested Query Pin
Tej Aj3-Mar-09 20:54
Tej Aj3-Mar-09 20:54 
GeneralRe: Nested Query Pin
Sajjad Leo3-Mar-09 22:29
Sajjad Leo3-Mar-09 22:29 
Question[Message Deleted] Pin
Prajeesh3-Mar-09 19:03
Prajeesh3-Mar-09 19:03 
AnswerRe: Popup Menu from a button Pin
Christian Graus3-Mar-09 19:43
protectorChristian Graus3-Mar-09 19:43 
GeneralRe: Popup Menu from a button Pin
Shyam K Pananghat3-Mar-09 20:56
Shyam K Pananghat3-Mar-09 20:56 
QuestionPlease Help Pin
techygeek3-Mar-09 18:47
techygeek3-Mar-09 18:47 
Hi all,

Guys i have project for searching engine and the idea is connecting Google Desktop Search (GDS) with C# application i foud some helpfull code which search for a file and return its path like this code
using System;
using System.IO;
using System.Net;
using System.Xml;
using Microsoft.Win32;
using System.Collections;
using System.Collections.Generic;
using System.Text;


namespace ConsoleApplication1
{
    class GDS
    {
        private string format = "&format=xml";
        public GDS()
        {
        }
        public ArrayList Search(string search, int num)
        {
            search = search.Replace(" ", "+");
            WebClient localGDS = new WebClient();
            string gdsResponse = null;
            try
            {
                StreamReader sr = new StreamReader(localGDS.OpenRead(getSearchQuery() + search + format + "&num=" + num.ToString()));
                gdsResponse = sr.ReadToEnd();
                sr.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return null;
            }
            ArrayList ar = new ArrayList();

            if (gdsResponse != null)
            {
                XmlDocument xmlDoc = new XmlDocument();
                try
                {
                    xmlDoc.LoadXml(gdsResponse);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    return null;
                }
                XmlNodeList resultsNode = xmlDoc.GetElementsByTagName("result");
                foreach (XmlNode result in resultsNode)
                {
                    XmlNodeList fields = result.ChildNodes;
                    Hashtable hash = new Hashtable();
                    foreach (XmlNode field in fields)
                    {

                        hash.Add(field.Name, field.InnerXml);
                    }
                    ar.Add(hash);
                }
            }
            return ar;
        }
        public ArrayList SearchOnlyFiles(string search, int num)
        {
            search = search.Replace(" ", "+");
            WebClient localGDS = new WebClient();
            string gdsResponse = null;
            try
            {
                StreamReader sr = new StreamReader(localGDS.OpenRead(getSearchQuery() + search + format + "&num=" + num.ToString() + "&flags=512"));
                gdsResponse = sr.ReadToEnd();
                sr.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return null;
            }
            ArrayList ar = new ArrayList();

            if (gdsResponse != null)
            {
                XmlDocument xmlDoc = new XmlDocument();
                try
                {
                    xmlDoc.LoadXml(gdsResponse);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    return null;
                }
                XmlNodeList resultsNode = xmlDoc.GetElementsByTagName("result");
                foreach (XmlNode result in resultsNode)
                {
                    XmlNodeList fields = result.ChildNodes;
                    Hashtable hash = new Hashtable();
                    foreach (XmlNode field in fields)
                    {

                        hash.Add(field.Name, field.InnerXml);
                    }
                    ar.Add(hash);
                }
            }
            return ar;
        }
        private string getSearchQuery()
        {
            RegistryKey currentUser = RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.CurrentUser, "");
            RegistryKey searchUrl = currentUser.OpenSubKey("Software\\Google\\Google Desktop\\API");
            object key = searchUrl.GetValue("search_url");
            return key.ToString();
        }
        [STAThread]
        static void Main(string[] args)
        {
            GDS gds = new GDS();
            string words = "java";
            ArrayList ar = gds.SearchOnlyFiles(words, 20);
            if (ar != null)
            {
                foreach (object o in ar)
                {
                    Hashtable hash = (Hashtable)o;
                    string category = (string)hash["category"];
                    if (category.Equals("file"))
                    {
                        Console.WriteLine("**********************************");
                        Console.WriteLine("File Found: " + (string)hash["url"]);
                    }
                }
            }
            Console.ReadLine();

        }
    }
}


i did a complete project in java which search for a file and return many things like url,las_date_modified, and content but in c# i couldn't found a documintation talking about GDS and its ability to connect GDS API with C# application please if some interest or has usefull information for me please help...
AnswerRe: Please Help Pin
Christian Graus3-Mar-09 20:03
protectorChristian Graus3-Mar-09 20:03 
GeneralRe: Please Help Pin
techygeek3-Mar-09 20:08
techygeek3-Mar-09 20:08 
QuestionHow to display multiple repeating records and groupng of that record in HTML Reports Pin
Nupur Rai3-Mar-09 18:04
Nupur Rai3-Mar-09 18:04 
AnswerRe: How to display multiple repeating records and groupng of that record in HTML Reports Pin
Shyam K Pananghat3-Mar-09 21:01
Shyam K Pananghat3-Mar-09 21:01 
QuestionRe: How to display multiple repeating records and groupng of that record in HTML Reports Pin
Nupur Rai3-Mar-09 22:25
Nupur Rai3-Mar-09 22:25 
QuestionHow to generate ENCRYPTED html file to pdf file using itext with C# [modified] Pin
YiXiang_893-Mar-09 16:34
YiXiang_893-Mar-09 16:34 
AnswerRe: How to generate ENCRYPTED html file to pdf file using itext with C# Pin
Christian Graus3-Mar-09 17:12
protectorChristian Graus3-Mar-09 17:12 
QuestionDataSets... Pin
Illegal Operation3-Mar-09 14:59
Illegal Operation3-Mar-09 14:59 
AnswerRe: DataSets... Pin
Christian Graus3-Mar-09 15:48
protectorChristian Graus3-Mar-09 15:48 
GeneralRe: DataSets... Pin
Illegal Operation3-Mar-09 16:00
Illegal Operation3-Mar-09 16:00 
GeneralRe: DataSets... Pin
Christian Graus3-Mar-09 16:04
protectorChristian Graus3-Mar-09 16:04 
GeneralRe: DataSets... Pin
Yusuf3-Mar-09 16:07
Yusuf3-Mar-09 16:07 
AnswerRe: DataSets... Pin
Ennis Ray Lynch, Jr.3-Mar-09 15:59
Ennis Ray Lynch, Jr.3-Mar-09 15:59 
AnswerRe: DataSets... Pin
faizicrazy3-Mar-09 22:00
faizicrazy3-Mar-09 22:00 
Questionwhat is image index ....???? Pin
S K Y3-Mar-09 14:26
S K Y3-Mar-09 14:26 
AnswerRe: what is image index ....???? Pin
Yusuf3-Mar-09 14:37
Yusuf3-Mar-09 14:37 
Question[Message Deleted] Pin
S K Y3-Mar-09 14:06
S K Y3-Mar-09 14:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.