How can I find out the size of the file (movie) inside the torrent file using C #?

1 answer 1

Try using the BencodeNET library

TorrentFile torrent = Bencode.DecodeTorrentFile("ИМЯ_ФАЙЛА"); string infoHash = torrent.CalculateInfoHash(); // Получить название, размер, полный путь файлов торрента списком. BList files = (BList)torrent.Info["files"]; foreach (BDictionary file in files) { // Размер файла в БАЙТАХ long size = (BNumber) file["length"]; // Полный путь файла, разбитый на директории BList path = (BList) file["path"]; // Название последнего элемента в пути файла BString fileName = (BString) path.Last(); // Перевод fileName в string string fileNameString = fileName.ToString(Encoding.UTF8); } 

A source

  • one
    Most of the libraries hosted on a githaba can be used via nuget. You do not have to download the source code nuget.org/packages/BencodeNET - Dmitry Dovgopoly
  • Comments are not intended for extended discussion; conversation moved to chat . - Nick Volynkin