【问题标题】:Unable to download file from a newly created torrent using monotorrent无法使用 monotorrent 从新创建的 torrent 下载文件
【发布时间】:2013-10-17 07:12:26
【问题描述】:

我使用以下代码在 monotorrent 解决方案中创建 torrent。但是“RawTrackerTier”缺少引用。当我评论那行代码时,我能够创建种子,但我无法从创建的种子下载文件。是因为缺少参考资料还是解决方案中的任何其他问题?如果是,任何人都可以提供缺少的参考资料吗? 请帮帮我!!

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);
}

【问题讨论】:

    标签: c# asp.net c#-4.0 bittorrent monotorrent


    【解决方案1】:

    nuget 上的MonoTorrent 版本(版本 0.9.0)相当旧,似乎只有单层宣布支持。如果您使用的是该版本,则此代码可能有效:

    // The class used for creating the torrent
    TorrentCreator c = new TorrentCreator();
    
    // Add tracker(s)
    c.Announces.Add("http://localhost/announce");
    

    monotorrent 的最新版本可在github 获得(仅代码)。您可以尝试下载库源并自己构建它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多