Solved

C# puts some word to search

Posted on 2010-11-28
4
394 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
ID: 34227332
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
ID: 34227336
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
ID: 34227451
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
ID: 34227522
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Achieve json result 2 65
Allow space in this pattern 2 49
SQL Login 17 40
Close form "before" open 3 28
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

861 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

30 Experts available now in Live!

Get 1:1 Help Now