[英]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? 我找到了一种获取种子文件的URL的方法,如果我具有字符串格式的文件,是否有一种方法可以让我在用户按下应用程序中的按钮时立即启动它?
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 )
并且不同的浏览器的行为也有所不同,并且可能无法遵循Windows文件扩展名(东西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.
.NET Frameworks提供了很好的解决方案,您可以自己下载文件。
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. 另外,如果您通过Proccess进行下载,那么您在下载时将不会获得推荐,某些站点可能会阻止您停止热链接。 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. 不知道这是否适合您,但是如果您已将torrent协议注册到已安装的应用程序中,则只需启动URL,就好像它是可执行文件的路径一样(例如,通过使用
Process
类)将启动该URL。关联的应用程序。 See here: http://kb.mozillazine.org/Register_protocol 看到这里: 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.
单击关联程序的“打开”即可控制。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.