Solved

C# puts some word to search

Posted on 2010-11-28
4
393 Views
Last Modified: 2012-05-10
System.Diagnostics.Process.Start(@"E:\Program Files\Mozilla Firefox\firefox.exe", "www.msn.com www.yahoo.com www.hotmail.com");


Can i put some key word to search after fire fox open 3 search engin   such as put

"song naran" in the search box of tree website that just open
0
Comment
Question by:teera
  • 3
4 Comments
 
LVL 13

Expert Comment

by:AngryBinary
Comment Utility
Yes. You will want to look at the format of the search query strings for those sites. For instance, on www.msn.com, the URL to use would be:

"http://www.bing.com/search?q=song+naran"

For Yahoo, use:

"http://search.yahoo.com/search?p=song+naran"

Hotmail would also use the Bing search engine, so you wouldn't need to open another tab for that to begin with. All you have to do is URL encode the search terms (). The full code snippet would look something like this:






string searchString = "song naran"; //or some value retrieved from a form

System.Diagnostics.Process.Start(
    @"E:\Program Files\Mozilla Firefox\firefox.exe", 
    String.Format(
        "http://www.bing.com/search?q={0} http://search.yahoo.com/search?p={0}", 
        HttpUtiltity.UrlEncode(searchString)));

Open in new window

0
 
LVL 13

Expert Comment

by:AngryBinary
Comment Utility
FYI, to use the HttpUtility class, you will need to add a reference to the System.Web namespace in your project.
0
 

Author Comment

by:teera
Comment Utility
Error      1      A using namespace directive can only be applied to namespaces; 'System.String' is a type not a namespace      C:\Users\¿¿¿7\documents\visual studio 2010\Projects\firefox\firefox\Form1.cs      


using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Web ;

using System.String;



namespace WindowsFormsApplication1

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }



        private void button1_Click(object sender, EventArgs e)

        {





            string searchString = "song naran"; //or some value retrieved from a form



            System.Diagnostics.Process.Start(

                @"E:\Program Files\Mozilla Firefox\firefox.exe",

                String.Format(

                    "http://www.bing.com/search?q={0} http://search.yahoo.com/search?p={0}",

                    HttpUtiltity.UrlEncode(searchString)));





            

        }

    }

}

Open in new window

0
 
LVL 13

Accepted Solution

by:
AngryBinary earned 500 total points
Comment Utility
Well, the exception is pretty self explanatory. You can't issue a "using" directive on a class. Remove "using System.String;" from your code.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now