public void FileAsync(string url)
        {
            try
            {

                Uri fileURI = new Uri(url);
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(fileURI);
                request.Method = "GET";
                request.Proxy = null;

                RequestState state = new RequestState();
                state.Request = request;
                state.FileURI = fileURI;
                state.TransferStart = DateTime.Now;

                IAsyncResult result = request.BeginGetResponse(new AsyncCallback(ResponseCallback), state);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Esempio n. 2
0
        private void Done(RequestState state)
        {
            string path = PluginSaveHelper.BuildSavePath(info, latest.CreationTime);
            File.WriteAllBytes(path, state.ResponseContent.ToArray());

            BuildVersion(path);
            EventProcessing(this, new PluginEventArgs(latest.ToString()));
        }
Esempio n. 3
0
        private void Done(RequestState state)
        {
            string path = PluginSaveHelper.BuildSavePath(info, latest.CreationTime, ".zip");
            File.WriteAllBytes(path, state.ResponseContent.ToArray());

            string tmp = Path.Combine(Path.GetDirectoryName(path), "tmp");
            System.IO.Compression.ZipFile.ExtractToDirectory(path, tmp);
            File.Delete(path);
            string[] files = Directory.GetFiles(tmp, "*.exe");
            if (files.Length == 0)
                return;

            string newpath = PluginSaveHelper.BuildSavePath(info, latest.CreationTime);
            if (File.Exists(newpath))
            {
                File.Delete(newpath);
            }

            File.Move(files[0], newpath);

            BuildVersion(newpath);

            Directory.Delete(tmp, true);
            EventProcessing(this, new PluginEventArgs(latest.ToString()));
        }