开发者

If I have the URL of a torrent, how can I just "launch" it using the Process.Start()?

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?


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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜