1st of all i wil tel ma problum,
i am using fire fox and i need to create a simple app on c# to shutdown the computer when a download(normal download) is over on fire fox .

so ......just tel me how to get the running fire fox process id ....and.............rest.Thanx

Comments
bad english

i do some modifications to that code.but the thing is i cant get the fire fox proces and how to catch the download finish process.

There is no download finished process that I know of. What are you trying to do? This sounds more like a browser plugin than a separate application.

You can probably get the firefox "Download" window by its caption but that won't indicate if the download has finished

There is no download finished process that I know of. What are you trying to do? This sounds more like a browser plugin than a separate application.

You can probably get the firefox "Download" window by its caption but that won't indicate if the download has finished

no this is not plugin but like a plugin.i am trying to run my app on the pc and trying to catch the action that firefox prompts "download is finish" the conner of the screen.

if i can cathch that proces i can give the command on my app to shutdown the computer.

so still i am stuck on geting that download finish msg from the running fire fox.

Why not have your application perform the download instead of monitoring another application?

excuse me ?

excuse me ?

This code allows you to pass the URL of the file you want to download from the web, along with a local path where to save the file, then will call a messagebox when completed, but you can do a shutdown when that event is called instead of MessageBox:

public static void Test()
        {
            DownloadFile dlf = new DownloadFile();
            //string url = @"http://www.daniweb.com/alphaimages/misc/logo/logo.gif";
            string url = @"http://upload.wikimedia.org/wikipedia/commons/thumb/7/75/Wikimedia_Community_Logo.svg/30px-Wikimedia_Community_Logo.svg.png";
            dlf.Download(url, @"c:\temp");
        }
        void Download(string url, string targetDir)
        {

            // Create an instance of WebClient
            WebClient client = new WebClient();

            // Hookup DownloadFileCompleted Event
            client.DownloadFileCompleted +=
                new AsyncCompletedEventHandler(client_DownloadFileCompleted);

            Uri uri = new Uri(url);
            string fileName = System.IO.Path.GetFileName(uri.LocalPath);
            string destFile = System.IO.Path.Combine(targetDir, fileName);

            try
            {
                // Start the download and copy the file to c:\temp
                client.DownloadFileAsync(uri, destFile);
            }
            catch (WebException e)
            {
                MessageBox.Show(e.Message);
            }
            catch (InvalidOperationException e)
            {
                MessageBox.Show(e.Message);
            }
        }

        void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            MessageBox.Show("File downloaded. OK to shutdown now...");
        }
Comments
Thats neat. I don't think i will mention how I have been downloading files :P

DUNNO guys... why would anyone download a file and then auto shutdown the computer??? Anyone any ideas? I have...

Hahah yeah... interesting... "I'm just clearing the temp files...!"

What the...? and shutting down the computer is your solution for that? To my knowledge temp files are retained after you reboot.... I know my temp directory is big :X

What the...? and shutting down the computer is your solution for that? To my knowledge temp files are retained after you reboot.... I know my temp directory is big :X

lol no I was being sarcastic :P

ya its ok.but the thing is i need to learn how to do my kind of problem.

and also downloading from firefox is bit fast(with the fire download plugin,10 X fast ).

Uh.. bandwidth is bandwidth. You can implement a gzip-compression enabled client with relative ease. Think of the internet as a series of tubes (you cannot increase pressure in internet tubes, though). Only so much stuff can go through. But what you can do is compress the stuff that goes through so you can send more of it faster at the expense of compression/decompression at either end. You could also use multiple GET requests with ranges to have downloading concurrency, but you don't want to exceed the 2 connection limit imposed by RFC2616.

Now that the workings of FireFox has been demystified, are you ready to write your own client? :)

This article has been dead for over six months. Start a new discussion instead.