Path() public static method

public static Path ( object path ) : void
path object
return void
示例#1
0
        /// <summary>
        ///     This method loads a .torrent file from the specified path.
        /// </summary>
        /// <param name="path">The path to load the .torrent file from</param>
        public static Torrent Load(string path)
        {
            Check.Path(path);

            using (Stream s = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
                return(Load(s, path));
        }
示例#2
0
        /// <summary>
        ///     Loads a .torrent from the specificed path. A return value indicates
        ///     whether the operation was successful.
        /// </summary>
        /// <param name="path">The path to load the .torrent file from</param>
        /// <param name="torrent">If the loading was succesful it is assigned the Torrent</param>
        /// <returns>True if successful</returns>
        public static bool TryLoad(string path, out Torrent torrent)
        {
            Check.Path(path);

            try
            {
                torrent = Load(path);
            }
            catch
            {
                torrent = null;
            }

            return(torrent != null);
        }
示例#3
0
        /// <summary>
        ///     Called from either Load(stream) or Load(string).
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        private static Torrent Load(Stream stream, string path)
        {
            Check.Stream(stream);
            Check.Path(path);

            try
            {
                var t = LoadCore((BEncodedDictionary)BEncodedValue.Decode(stream));
                t.TorrentPath = path;
                return(t);
            }
            catch (BEncodingException ex)
            {
                throw new TorrentException("Invalid torrent file specified", ex);
            }
        }