BitTorrent.Torrent.OpenTorrent C# (CSharp) Method

OpenTorrent() private method

private OpenTorrent ( string localFilename ) : bool
localFilename string
return bool
        internal bool OpenTorrent(string localFilename)
        {
            data = null; // clear any old data
            bool hasOpened = false;
            localTorrentFile = localFilename;
            data = new ValueDictionary();
            FileStream fs = null;
            BinaryReader r = null;

            try
            {
                fs = File.OpenRead(localFilename);
                r = new BinaryReader(fs);

                // Parse the BEncode .torrent file
                data = (ValueDictionary)BEncode.Parse(r.BaseStream);

                // Check the torrent for its form, initialize this object
                LoadTorrent();

                hasOpened = true;
                r.Close();
                fs.Close();
            }
            catch (IOException)
            {
                hasOpened = false;
            }
            finally
            {
                if (r != null) r.Close();
                if (fs != null) fs.Close();
            }

            return hasOpened;
        }