首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用monotorrent从新创建的torrent下载文件

无法使用monotorrent从新创建的torrent下载文件
EN

Stack Overflow用户
提问于 2013-10-17 15:12:26
回答 1查看 851关注 0票数 0

我使用以下代码在monotorrent解决方案中创建torrent。但是缺少对“RawTrackerTier”的引用,当我注释代码行时,.I能够创建torrent,但我无法从创建的torrent下载文件。是因为丢失的引用还是解决方案中的任何其他问题?如果是,有人可以提供丢失的引用吗?请帮帮我!!

代码语言:javascript
复制
public void CreateTorrent(string path, string savePath)
{
    // The class used for creating the torrent
    TorrentCreator c = new TorrentCreator();

    // Add one tier which contains two trackers
    RawTrackerTier tier = new RawTrackerTier(); // MISSING REFERENCE HERE
    tier.Add("http://localhost/announce");

    c.Announces.Add(tier);
    c.Comment = "This is the comment";
    c.CreatedBy = "Doug using " + VersionInfo.ClientVersion;
    c.Publisher = "www.aaronsen.com";

    // Set the torrent as private so it will not use DHT or peer exchange
    // Generally you will not want to set this.
    c.Private = true;

    // Every time a piece has been hashed, this event will fire. It is an
    // asynchronous event, so you have to handle threading yourself.
    c.Hashed += delegate(object o, TorrentCreatorEventArgs e)
    {
        Console.WriteLine("Current File is {0}% hashed", e.FileCompletion);
        Console.WriteLine("Overall {0}% hashed", e.OverallCompletion);
        Console.WriteLine("Total data to hash: {0}", e.OverallSize);
    };

    // ITorrentFileSource can be implemented to provide the TorrentCreator
    // with a list of files which will be added to the torrent metadata.
    // The default implementation takes a path to a single file or a path
    // to a directory. If the path is a directory, all files will be
    // recursively added

    ITorrentFileSource fileSource = new TorrentFileSource(path);

    // Create the torrent file and save it directly to the specified path
    // Different overloads of 'Create' can be used to save the data to a Stream
    // or just return it as a BEncodedDictionary (its native format) so it can be
    // processed in memory
    c.Create(fileSource, savePath);
}
EN

回答 1

Stack Overflow用户

发布于 2013-10-17 16:01:30

nuget上的MonoTorrent版本(0.9.0版)相当旧,似乎只支持单层公告。如果您使用的是该版本,下面的代码可能会起作用:

代码语言:javascript
复制
// The class used for creating the torrent
TorrentCreator c = new TorrentCreator();

// Add tracker(s)
c.Announces.Add("http://localhost/announce");

github上提供了最新版本的monotorrent (仅限代码)。您可以尝试下载库源代码并自己构建它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19420408

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档