简体   繁体   English

如果我具有洪流的URL,如何使用Process.Start()“启动”它?

[英]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.

相关问题 如何使用Process.Start启动管道并重定向命令? - How can I launch pipes and redirects commands with Process.Start? 为什么我不能使用 Process.Start 启动 Robocopy - Why i can't launch Robocopy with Process.Start 我必须处理 Process.Start(url) 吗? - Do I have to Dispose Process.Start(url)? 使用Process.Start()时,如何在程序运行期间保持cmd提示符打开? - When using Process.Start(), how can I keep the cmd prompt open for the duration of the program? 如何使用.NET Process.Start()设置应用程序的窗口文本? - How can I set the window text of an application using .NET Process.Start()? 如何使用process.start启动setup.exe文件 - How to launch a setup.exe file using process.start 使用Process.Start启动WPF应用程序 - Launch WPF application using Process.Start 为什么我可以使用Windows服务以交互方式启动给定的应用程序,而不能将其作为服务启动? (过程开始) - Why can I start a given application using a Windows Service in interactive mode, but not as a service? (Process.Start) 使用 Process.Start 时无法登录 Skype - Can't log to Skype when I use Process.Start 当我使用Process.Start()运行该程序时,如何强制另一个程序不显示任何对话框 - How can I force another program to not show any dialog when I run it with Process.Start()
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM