TorrentFile Class

public sealed class TorrentFile

No documentation is available.

Constructors

NameDescription
TorrentFile()

TorrentFile()

TorrentFile.cs
public TorrentFile()

No documentation is available.

Properties

NameDescription
Announce
AnnounceList
Comment
CreatedBy
CreationDate
EncodingThe 'encoding' key naming the code page the text fields were written with.
HttpSeedsWeb seed URLs from the 'httpseeds' key (BEP 17).
InfoThe metainfo dictionary. Replacing it discards the parsed bytes, so the info-hash is recomputed from the model.
NodesDHT bootstrap nodes from the 'nodes' key (BEP 5).
Publisher
PublisherUrlThe 'publisher-url' key. Kept as text because the metainfo value is not guaranteed to be a well-formed URI.
UrlListWeb seed URLs from the 'url-list' key (BEP 19).
public string? Announce { get; set; }

Property value

string?

No documentation is available.

AnnounceList

TorrentFile.cs
public IReadOnlyList<IReadOnlyList<string>>? AnnounceList { get; set; }

No documentation is available.

public string? Comment { get; set; }

Property value

string?

No documentation is available.

public string? CreatedBy { get; set; }

Property value

string?

No documentation is available.

CreationDate

TorrentFile.cs
public DateTimeOffset? CreationDate { get; set; }

Property value

DateTimeOffset?

No documentation is available.

The 'encoding' key naming the code page the text fields were written with.

public string? Encoding { get; set; }

Property value

string?

Web seed URLs from the 'httpseeds' key (BEP 17).

public IReadOnlyList<string>? HttpSeeds { get; set; }

The metainfo dictionary. Replacing it discards the parsed bytes, so the info-hash is recomputed from the model.

public TorrentInfo Info { get; set; }

Property value

TorrentInfo

DHT bootstrap nodes from the 'nodes' key (BEP 5).

public IReadOnlyList<TorrentNode>? Nodes { get; set; }
public string? Publisher { get; set; }

Property value

string?

No documentation is available.

PublisherUrl

TorrentFile.cs

The 'publisher-url' key. Kept as text because the metainfo value is not guaranteed to be a well-formed URI.

public string? PublisherUrl { get; set; }

Property value

string?

Web seed URLs from the 'url-list' key (BEP 19).

public IReadOnlyList<string>? UrlList { get; set; }

Property value

IReadOnlyList<string>?

Remarks

BEP 19 allows a bare string as well as a list; both are read into this list, and it is always written back as a list.

Methods

NameDescription
GetInfoHashSha1()Computes the BitTorrent v1 info-hash.
GetInfoHashSha256()Computes the SHA-256 of the 'info' dictionary.
Parse(ReadOnlySpan<byte>)
ParseAsync(Stream, CancellationToken)
ToUtf8ByteArray(bool)
TryParse(ReadOnlySpan<byte>, TorrentFile?)
WriteToAsync(Stream, bool, CancellationToken)

GetInfoHashSha1()

TorrentFile.cs

Computes the BitTorrent v1 info-hash.

public byte[] GetInfoHashSha1()

Returns

byte[]

Remarks

For a parsed torrent this hashes the exact bytes the 'info' dictionary was read from, so keys this model does not represent still contribute to the hash.

GetInfoHashSha256()

TorrentFile.cs

Computes the SHA-256 of the 'info' dictionary.

public byte[] GetInfoHashSha256()

Returns

byte[]

Remarks

For a parsed torrent this hashes the exact bytes the 'info' dictionary was read from, so keys this model does not represent still contribute to the hash.

Parse(ReadOnlySpan<byte>)

TorrentFile.cs
public static TorrentFile Parse(ReadOnlySpan<byte> data)

Parameters

data ReadOnlySpan<byte>

Returns

TorrentFile

No documentation is available.

ParseAsync(Stream, CancellationToken)

TorrentFile.cs

net10.0

public static ValueTask<TorrentFile> ParseAsync(Stream stream, CancellationToken cancellationToken = default)

net11.0

public static ValueTask<TorrentFile> ParseAsync(Stream stream, CancellationToken cancellationToken = default)

Parameters

stream Stream
cancellationToken CancellationToken

Returns

ValueTask<TorrentFile>

No documentation is available.

ToUtf8ByteArray(bool)

TorrentFile.cs
public byte[] ToUtf8ByteArray(bool canonical = true)

Parameters

canonical bool

Returns

byte[]

No documentation is available.

TryParse(ReadOnlySpan<byte>, TorrentFile?)

TorrentFile.cs
public static bool TryParse(ReadOnlySpan<byte> data, out TorrentFile? result)

Parameters

data ReadOnlySpan<byte>
result TorrentFile?

Returns

bool

No documentation is available.

WriteToAsync(Stream, bool, CancellationToken)

TorrentFile.cs

net10.0

public ValueTask WriteToAsync(Stream stream, bool canonical = true, CancellationToken cancellationToken = default)

net11.0

public ValueTask WriteToAsync(Stream stream, bool canonical = true, CancellationToken cancellationToken = default)

Parameters

stream Stream
canonical bool
cancellationToken CancellationToken

Returns

ValueTask

No documentation is available.