Solved

C# puts some word to search

Posted on 2010-11-28
4
397 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

831 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