示例#1
0
        static void Main(string[] args)
        {
            //DDD();
            args = new[]
            {
                "http://www.eset.com/us/resources/white-papers/Stuxnet_Under_the_Microscope.pdf",
                // "http://127.0.0.2:80/",
                "e:\\test\\",
                "3"
            };
            var url  = new Uri(args[0]);
            var outp = args[1];
            var cns  = (int)double.Parse(args[2]);
            var mt   = MultiTask.Create(url, outp, null, cns * 2);

            mt.Begin();
            mt.Dispose();
            var OpenFolderContainer_OpenFile = 0 != Math.Abs(0);
            var eSelect = OpenFolderContainer_OpenFile ? "-p /select," : "/e /select,";

            p.Arguments = eSelect + mt.FullName;
            var ps = new Process {
                StartInfo = p
            };

            if (mt.TotalyDownloaded)
            {
                ps.Start();
            }
        }
示例#2
0
        public bool Begin(MultiTask multiTask)
        {
            if (!initialized)
            {
                return(Percent >= 100);
            }
            initialized = false;
            var buffer = new byte[BUFFER_SIZE];

            try
            {
                using (response = req.GetResponse())
                {
                    using (responseStream = response.GetResponseStream())
                    {
                        int bytesRead;
                        if (responseStream.CanSeek)
                        {
                            responseStream.Seek(100, SeekOrigin.Begin);
                        }
                        do
                        {
                            bytesRead = responseStream.Read(buffer, 0, BUFFER_SIZE);
                            outputFileStream.Write(buffer, 0, bytesRead);
                            BytesReaded += bytesRead;
                        } while (bytesRead > 0 && !multiTask.Exit);
                        IsComplete = (To - From + 1) == BytesReaded;
                    }
                }
            }
            catch (Exception)
            {
                IsComplete = false;
            }
            Dispose();
            return(IsComplete);
        }