Hi there,
I have installed Visual C# 2010 Express and have downloaded the MonoTorrent API and am now trying to download a torrent file. I'm very new to this programming environment - previously just used a text editor for .ASP and .PHP apps as well as vbscript and so on - so please excuse my ignorance!
I have added various "references" which seem to be important and in addition to that I have two programs - one is called GetTorrent.cs and one is called Program.cs
GetTorrent.cs
Program.cs
When I click the play button it runs without errors but nothing happens. I know one of the most likely reasons is that I have not specified the name of the .torrent file to download but I can't figure out how to do this. The "test" parameter seems to be where the file gets saved but again I'm not entirely sure on this!
Any help very much appreciated!
Thanks
Ed
I have installed Visual C# 2010 Express and have downloaded the MonoTorrent API and am now trying to download a torrent file. I'm very new to this programming environment - previously just used a text editor for .ASP and .PHP apps as well as vbscript and so on - so please excuse my ignorance!
I have added various "references" which seem to be important and in addition to that I have two programs - one is called GetTorrent.cs and one is called Program.cs
GetTorrent.cs
Code:
using System;
using System.Collections.Generic;
using MonoTorrent.Client;
using MonoTorrent.Client.Encryption;
using System.IO;
using MonoTorrent.Common;
using System.Net;
namespace TorrentDownloader
{
class MainClass
{
ClientEngine engine;
string savePath;
// savePath is the directory where downloads will be stored
public MainClass(string savePath)
{
// Create a basic ClientEngine without changing any settings
this.engine = new ClientEngine(new EngineSettings());
this.savePath = savePath;
}
public void DownloadTorrent(string path)
{
// Open the .torrent file
Torrent torrent = Torrent.Load(path);
// Create the manager which will download the torrent to savePath
// using the default settings.
TorrentManager manager = new TorrentManager(torrent, savePath, new TorrentSettings());
// Register the manager with the engine
engine.Register(manager);
// Begin the download. It is not necessary to call HashCheck on the manager
// before starting the download. If a hash check has not been performed, the
// manager will enter the Hashing state and perform a hash check before it
// begins downloading.
// If the torrent is fully downloaded already, calling 'Start' will place
// the manager in the Seeding state.
manager.Start();
}
}
}
Program.cs
Code:
using System;
using System.Collections.Generic;
using System.Text;
namespace TorrentDownloader
{
class Program
{
static void Main(string[] args)
{
new MainClass("test");
}
}
}
When I click the play button it runs without errors but nothing happens. I know one of the most likely reasons is that I have not specified the name of the .torrent file to download but I can't figure out how to do this. The "test" parameter seems to be where the file gets saved but again I'm not entirely sure on this!
Any help very much appreciated!
Thanks
Ed