views:

86

answers:

3

I found a way to obtain the URL of a torrent file, if I have this in string format, is there a way for me to just launch it whenever a user presses a button in my app?

I know I could save the file and then call it up, but I'd rather just open it. Is this possible?

+1  A: 

You can just start it, but what will happen then is your default browser will open and it will download the file. And depending on the local settings on that machine it will do the default thing. I would not recommend this method, it means the end user will have to do alot of extra steps. And the different browsers behave differently, and may not obey windows file extentions ( thing firefox )

If your doing this inside a application you should download it yourself, you can read about that here. .NET Frameworks offers great solutions to download the file yourself.

Also if you do it via Proccess you will not get a refere when downloading, some sites may then block you to stop hot linking. but if you control the download class you can send a refere url

EKS
My plan is to let the user do with the torrent whatever he wants. I know I would be PISSED if a torrent searcher used it's own program to do things.
Sergio Tapia
Then give him a dialog saying "Run" or "Save" :) Updated my reply to include refere
EKS
@Papuccino1 - I think you should read the answer more carefully before dismissing it.
Chris Shouts
What EKS is saying is that you don't have the torrent yet. All you have it the url. So your program wont be doing anything with the torrent file apart from downloading it (the .torrent) and then letting the user / operating system do whatever they wish with it.
DavidGouge
@Papuccino1 - "to just launch it" ... launch it how?
Philip Wallace
What @Rubens Farias posted, will just launch it.
EKS
A: 

Don't know if this is OK for you, but if you have the torrent protocol registered to an installed application, simply launching the URL as if it were the path of an executable file (for example by using the Process class) will launch the associated application. See here: http://kb.mozillazine.org/Register_protocol

Konamiman
A: 

Try this:

Process p = new Process();
p.StartInfo.FileName = "http://domain/folder/file.torrent";
p.Start();

Or, if you like one-liners:

new Process
{ 
    StartInfo = new ProcessStartInfo
    {
        FileName = "http://domain/folder/file.torrent"
    }
}.Start();

That will call your default browser to download that file and tries to open it. Clicking "Open" you associate program takes control.

Rubens Farias