h1. Managing Torrents [[Managing Torrents#Example-1|Example 1]] shows how to add a torrent to the engine and start the download h2. Example 1

    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
            manager.Start();
        }
    }
h2. Advanced Client



ClientEngine engine = new ClientEngine(new EngineSettings(downloadsPath, port));

//DHT
DhtListener dhtListner = new UdpListener (new IPEndPoint (IPAddress.Any, port));
DhtEngine dht = new DhtEngine (dhtListner);
engine.RegisterDht(dht);
dhtListner.Start();
//byte array of dht nodes can be null if you have never connect to DHT before today!
engine.DhtEngine.Start(nodes);


torrent = Torrent.Load("test.torrent");
TorrentManager manager = new TorrentManager(torrent, downloadsPath, torrentDefaults);

//FastResume code need a BencodedDictionnary
//If you jsut start the torrent, you have no fast resume
// but if you have download a part of the torrent you can save fast resume data 
//(manager.SaveFastResume()) and restore it later to do a quicker load
manager.LoadFastResume(new FastResume (BEncDictFastResume));

engine.Register(manager);
manager.Start ();