当前位置: 首页>>代码示例>>C#>>正文


C# System.Net.WebClient.DownloadFileAsync方法代码示例

本文整理汇总了C#中System.Net.WebClient.DownloadFileAsync方法的典型用法代码示例。如果您正苦于以下问题:C# System.Net.WebClient.DownloadFileAsync方法的具体用法?C# System.Net.WebClient.DownloadFileAsync怎么用?C# System.Net.WebClient.DownloadFileAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.WebClient的用法示例。


在下文中一共展示了System.Net.WebClient.DownloadFileAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DownloadApp

 public void DownloadApp(object data)
 {
     webClient = new System.Net.WebClient();
     webClient.DownloadProgressChanged += webClient_DownloadProgressChanged;
     webClient.DownloadFileCompleted += webClient_DownloadFileCompleted;
     var url = Server.ServerUrl() + "/apps/" + appDisplay.PkgId + "/download";
     //MessageBox.Show();
     webClient.DownloadFileAsync(new Uri(url), targetFileName);
 }
开发者ID:MoriEdan,项目名称:cameyo,代码行数:9,代码来源:Playing.xaml.cs

示例2: button2_Click

 private void button2_Click(object sender, EventArgs e)
 {
     if (System.IO.File.Exists("Data2Serial2Update.exe"))
     {
         MessageBox.Show("In order to download the update again, you have to delete it manually. There will be an explorer window opening for this purpose.", "Update", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0);
         System.Diagnostics.Process.Start("explorer.exe", "/select," + "Data2Serial2Update.exe");
     }
     else
     {
         System.Net.WebClient wc3 = new System.Net.WebClient();
         wc3.DownloadProgressChanged += new System.Net.DownloadProgressChangedEventHandler(wc3_DownloadProgressChanged);
         wc3.DownloadFileCompleted += new AsyncCompletedEventHandler(wc3_DownloadFileCompleted);
         wc3.DownloadFileAsync(new Uri(downloadLink), "Data2Serial2Update.exe");
     }
 }
开发者ID:theaob,项目名称:Data2Serial2,代码行数:15,代码来源:Updater.cs

示例3: Download

        /// <summary>
        /// 执行文件或字符串下载
        /// </summary>
        /// <returns></returns>
        public bool Download()
        {
            if (System.IO.File.Exists(LocalPath)) System.IO.File.Delete(LocalPath);

            bool finished = false;
            bool error = false;

            System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(LocalPath));

            try
            {
                var client = new System.Net.WebClient();
                client.DownloadProgressChanged += (s, e) =>
                {
                    ReportProgress((int)e.TotalBytesToReceive, (int)e.BytesReceived);
                };

                if (!string.IsNullOrEmpty(LocalPath))
                {
                    client.DownloadFileCompleted += (s, e) =>
                    {
                        if (e.Error != null)
                        {
                            this.Exception = e.Error;
                            error = true;
                        }
                        finished = true;
                    };
                    client.DownloadFileAsync(new System.Uri(DownloadUrl), LocalPath);
                }
                else
                {
                    client.DownloadStringCompleted += (s, e) =>
                    {
                        if (e.Error != null)
                        {
                            this.Exception = e.Error;
                            error = true;
                        }
                        finished = true;
                        this.LocalPath = e.Result;
                    };
                    client.DownloadStringAsync(new System.Uri(DownloadUrl));
                }

                //没下载完之前持续等待
                while (!finished)
                {
                    Thread.Sleep(50);
                }
            }
            catch (Exception ex)
            {
                this.Exception = ex;
                return false;
            }

            if (error) return false;

            return true;
        }
开发者ID:jiguixin,项目名称:MyLibrary,代码行数:65,代码来源:PackageDownloader.cs

示例4: DownloadFile

        private void DownloadFile(ClipData clip, string folder)
        {
            string url = String.Format("http://{0}/DownloadFile.php?clip_id={1}", mediamanager.Server, clip.ID);
            System.Net.HttpWebRequest wr = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
            wr.CookieContainer = new System.Net.CookieContainer();
            System.Net.Cookie cookie = new System.Net.Cookie("SESS1", mediamanager.ImpersonationToken, "/", mediamanager.Server);
            wr.CookieContainer.Add(cookie);
            System.IO.Stream stream = wr.GetResponse().GetResponseStream();
            HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
            doc.Load(stream);
            foreach (HtmlNode link in doc.DocumentNode.SelectNodes("//a[@href]"))
            {
                HtmlAttribute att = link.Attributes["href"];
                url = att.Value;
                break;
            }

            System.Net.WebClient webClient = new System.Net.WebClient();
            webClient.DownloadProgressChanged += (s, e) =>
            {
                if(e.ProgressPercentage > 0)
                {
                    progressBar.Value = e.ProgressPercentage;
                }
            };
            webClient.DownloadFileCompleted += (s, e) =>
            {
                MessageBox.Show("Download complete");
            };
            webClient.DownloadFileAsync(new Uri(url), folder + @"\video.mp4");
        }
开发者ID:Granicus,项目名称:archivist,代码行数:31,代码来源:Form1.cs

示例5: performUpdate

        public static bool performUpdate(String DownloadLink, String savePath, String backupPath, String myFile, int Update)
        {
            if (File.Exists(savePath)) //No download conflict, Please :3 (Looks at Mono)
            {
                try
                {
                    File.Delete(savePath);
                }
                catch (Exception e)
                {
                    ProgramLog.Log (e, "Error deleting old file");
                    return false;
                }
            }

            if (!MoveFile(myFile, backupPath))
            {
                ProgramLog.Log ("Error moving current file!");
                return false;
            }

            var download = new System.Net.WebClient();
            Exception error = null;
            using (var prog = new ProgressLogger (100, "Downloading update " + Update.ToString() + "/" + MAX_UPDATES.ToString() + " from server"))
            {
                var signal = new System.Threading.AutoResetEvent (false);

                download.DownloadProgressChanged += (sender, args) =>
                {
                    prog.Value = args.ProgressPercentage;
                };

                download.DownloadFileCompleted += (sender, args) =>
                {
                    error = args.Error;
                    signal.Set ();
                };

                download.DownloadFileAsync(new Uri (DownloadLink), savePath);

                signal.WaitOne ();
            }

            if (error != null)
            {
                ProgramLog.Log (error, "Error downloading update");
                return false;
            }

            //Program.tConsole.Write("Finishing Update...");

            if (!MoveFile(savePath, myFile))
            {
                ProgramLog.Log ("Error moving updated file!");
                return false;
            }

            return true;
        }
开发者ID:CaptainMuscles,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:59,代码来源:UpdateManager.cs

示例6: WebBrowser_DocumnetCompleted

        private void WebBrowser_DocumnetCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            toolStripStatusLabel1.Text = loadingFileText;
            HtmlElementCollection theElementCollection = default(HtmlElementCollection);
            theElementCollection = webBrowser1.Document.GetElementsByTagName(htmlTagNameText);
            dirpath = sa[1] + dirDelimeter + sa[3].Split('.')[0];
            System.IO.Directory.CreateDirectory(dirpath);
            toolStripProgressBar1.Maximum = theElementCollection.Count+1;

            foreach (HtmlElement curElement in theElementCollection)
            {
                toolStripProgressBar1.Value++;
                if (curElement.GetAttribute(htmlClass).ToString() == htmlAttribute)
                {
                    string s = "http://" + sa[0] + delimeterHtmlAddress + sa[1] + sourceText + curElement.InnerText.Split(' ')[0];
                    System.Net.WebClient wc = new System.Net.WebClient();

                    filepath = Environment.CurrentDirectory + dirDelimeter + dirpath + dirDelimeter + curElement.InnerText.Split(' ')[0];
                    if (System.IO.File.Exists(filepath))
                    {
                        continue;
                    }
                    wc.DownloadFileAsync(new Uri(s), @filepath);
                }

            }
            toolStripStatusLabel1.Text = allImageDownloaded;
            toolStripProgressBar1.Value = 0;
            notifyIcon1.ShowBalloonTip(300, "Уведомление", "Скачено.", ToolTipIcon.None);
        }
开发者ID:Alsirion,项目名称:DIS,代码行数:30,代码来源:DIS_Form.cs

示例7: buttonDownload_Click

        private void buttonDownload_Click(object sender, EventArgs e)
        {
            //download the files in the File List box
            webClient = new System.Net.WebClient();
            this.Cursor = Cursors.WaitCursor;

            //System.Collections.ArrayList localFiles = new System.Collections.ArrayList();

            webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(webClient_DownloadFileCompleted);
            webClient.DownloadProgressChanged += new System.Net.DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
            foreach (string file in listFiles.Items)
            {
                string f = System.IO.Path.GetFileName(file);
                //System.Diagnostics.Debug.WriteLine(f);
                if (File.Exists(currentFolder + System.IO.Path.DirectorySeparatorChar + f))
                    File.Delete(currentFolder + System.IO.Path.DirectorySeparatorChar + f);

                System.Diagnostics.Debug.WriteLine(file);

                Uri uri = new Uri(file);
                localFiles.Push(uri);
                moveFiles.Push(uri);

            }
            Uri u = localFiles.Pop();
            string localFile = Path.GetFileName(u.ToString());
            currentFile = u.ToString();
            labelCurrentFile.Text = currentFile;

            webClient.DownloadFileAsync(u, currentFolder + System.IO.Path.DirectorySeparatorChar + localFile);
        }
开发者ID:origins,项目名称:ICEChat,代码行数:31,代码来源:FormUpdater.cs

示例8: UpdateServer

        public ActionResult UpdateServer(string ver)
        {
            // http://assets.minecraft.net/ <- This is an XML file
            // http://assets.minecraft.net/V_E_R/minecraft_server.jar
            // Old Stuff, from beta 1.8 pre till 1.5.2, and from 11w47 till 13w12 snapshots

            // https://s3.amazonaws.com/Minecraft.Download/versions/versions.json
            // https://s3.amazonaws.com/Minecraft.Download/versions/V.E.R/minecraft_server.V.E.R.jar
            // Minimum Available Server Version: 1.2.5

            var client = new System.Net.WebClient();
            client.CachePolicy = new RequestCachePolicy(RequestCacheLevel.CacheIfAvailable);

            HttpContext.Application["UpdateProgress"] = "Starting...";

            // Get Latest Version
            if (ver.StartsWith("Latest"))
            {
                var jObj = JObject.Parse(client.DownloadString(
                    "https://s3.amazonaws.com/Minecraft.Download/versions/versions.json"));
                ver = jObj["latest"][ver.Split(' ')[1].ToLower()].Value<string>();
            }

            var jarFile = "minecraft_server." + ver + ".jar";
            var jarUri = "https://s3.amazonaws.com/Minecraft.Download/versions/" + ver + "/" + jarFile;

            var config = WebConfig.OpenWebConfiguration("~");
            var settings = config.AppSettings.Settings;

            client.DownloadProgressChanged += (o, e) =>
                HttpContext.Application["UpdateProgress"] = e.ProgressPercentage + "%";

            client.DownloadFileCompleted += (o, e) =>
            {
                if (e.Error != null)
                {
                    HttpContext.Application["UpdateProgress"] = "Error: " + e.Error;
                    return;
                }

                HttpContext.Application["UpdateProgress"] = "Completed";

                settings["McJarFile"].Value = jarFile;
                config.Save();
            };

            HttpContext.Application["UpdateProgress"] = "0%";
            System.Threading.Tasks.Task.Run(() => // Workaround to allow Async call
            {
                try
                {
                    client.DownloadFileAsync(new Uri(jarUri), settings["McServerPath"].Value + jarFile);
                }
                catch (Exception ex)
                {
                    HttpContext.Application["UpdateProgress"] = "Error: " + ex;
                }
            });

            return Content("OK " + DateTime.Now.Ticks);
        }
开发者ID:hassanselim0,项目名称:MinecraftWebToolkit,代码行数:61,代码来源:AdminController.cs

示例9: Run

		/// <summary>Runs the <see cref="Downloader"/>.</summary>
		/// <remarks>
		/// The download is done in steps:
		/// <para>Firstly, the appropriate version file in the application data directory is locked,
		/// so that no other program can use it, until this program ends.</para>
		/// <para>Then, the version file is downloaded from the remote location.</para>
		/// <para>If there is already a valid version file in the download directory,
		/// and the version obtained from the remote version file is equal to the version obtained from the version file in the download directory,
		/// then the package was already downloaded before. Then we only check that the package file is also present and that it has the appropriate hash sum.</para>
		/// <para>Else, if the version obtained from the remote version file is higher than the program's current version,
		/// we download the package file from the remote location.</para>
		/// </remarks>
		public void Run()
		{
			if (!Directory.Exists(_storagePath))
			{
				Directory.CreateDirectory(_storagePath);
				SetDownloadDirectoryAccessRights(_storagePath);
			}

			var versionFileFullName = Path.Combine(_storagePath, PackageInfo.VersionFileName);
			using (FileStream fs = new FileStream(versionFileFullName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None))
			{
				fs.Seek(0, SeekOrigin.Begin);
				var alreadyDownloadedVersion = PackageInfo.GetPresentDownloadedPackage(fs, _storagePath);
				fs.Seek(0, SeekOrigin.Begin);

				using (var webClient = new System.Net.WebClient())
				{
					Console.Write("Starting to download version file ...");
					var versionData = webClient.DownloadData(_downloadURL + PackageInfo.VersionFileName);
					Console.WriteLine(" ok! ({0} bytes downloaded)", versionData.Length);
					// we leave the file open, thus no other process can access it
					var parsedVersions = PackageInfo.FromStream(new MemoryStream(versionData));

					fs.Write(versionData, 0, versionData.Length);
					fs.Flush(); // write the new version to disc in order to change the write date

					// from all parsed versions, choose that one that matches the requirements
					PackageInfo parsedVersion = PackageInfo.GetHighestVersion(parsedVersions);

					if (null != parsedVersion)
					{
						Console.WriteLine("The remote package version is: {0}", parsedVersion.Version);
					}
					else
					{
						Console.WriteLine("This computer does not match the requirements of any package. The version file contains {0} packages.", parsedVersions.Length);
						return;
					}

					if (Comparer<Version>.Default.Compare(parsedVersion.Version, _currentVersion) > 0) // if the remote version is higher than the currently installed Altaxo version
					{
						Console.Write("Cleaning download directory ...");
						CleanDirectory(versionFileFullName); // Clean old downloaded files from the directory
						Console.WriteLine(" ok!");

						var packageUrl = _downloadURL + PackageInfo.GetPackageFileName(parsedVersion.Version);
						var packageFileName = Path.Combine(_storagePath, PackageInfo.GetPackageFileName(parsedVersion.Version));
						Console.WriteLine("Starting download of package file ...");
						webClient.DownloadProgressChanged += EhDownloadOfPackageFileProgressChanged;
						webClient.DownloadFileCompleted += EhDownloadOfPackageFileCompleted;
						_isDownloadOfPackageCompleted = false;
						webClient.DownloadFileAsync(new Uri(packageUrl), packageFileName);// download the package asynchronously to get progress messages
						for (; !_isDownloadOfPackageCompleted; )
						{
							System.Threading.Thread.Sleep(250);
						}
						webClient.DownloadProgressChanged -= EhDownloadOfPackageFileProgressChanged;
						webClient.DownloadFileCompleted -= EhDownloadOfPackageFileCompleted;

						Console.WriteLine("Download finished!");

						// make at least the test for the right length
						var fileInfo = new FileInfo(packageFileName);
						if (fileInfo.Length != parsedVersion.FileLength)
						{
							Console.WriteLine("Downloaded file length ({0}) differs from length in VersionInfo.txt {1}, thus the downloaded file will be deleted!", fileInfo.Length, parsedVersion.FileLength);
							fileInfo.Delete();
						}
						else
						{
							Console.WriteLine("Test file length of downloaded package file ... ok!");
						}
					}
				}
			}
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:88,代码来源:UpdateDownloader.cs

示例10: CheckForUpdates

		private void CheckForUpdates(Boolean forceCheck)
		{
			Assembly a = Assembly.GetExecutingAssembly();

			// If this isn't null, we're trying to update to a version
			if (!forceCheck && System.Windows.Application.Current.Properties["Update"] != null)
			{
				System.Net.WebClient wClient = new System.Net.WebClient();
				wClient.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(wClient_DownloadFileCompleted);
				wClient.DownloadProgressChanged += new System.Net.DownloadProgressChangedEventHandler(wClient_DownloadProgressChanged);
				wClient.DownloadFileAsync(new Uri(System.Windows.Application.Current.Properties["Update"].ToString()), System.IO.Path.Combine(System.IO.Path.GetDirectoryName(a.Location), "update.zip"));
			}
			else
			{
				if (System.Windows.Application.Current.Properties["Updated"] != null && (Boolean)System.Windows.Application.Current.Properties["Updated"])
				{
					wMessageBox.Show(String.Format("Successfully updated to latest version {0}!", a.GetName().Version), "Update complete!", MessageBoxButton.OK, MessageBoxImage.Information);
					_Settings.UpdateAvailable = false;
					_Settings.Save();
				}

				String tempPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(a.Location), "update");
				// Blow away any existing files
				if (System.IO.Directory.Exists(tempPath))
					System.IO.Directory.Delete(tempPath, true);

				iUpdate.Dispatcher.BeginInvoke((Action)(() => iUpdate.Visibility = miDownload.Visibility = System.Windows.Visibility.Collapsed));

				// Only check for an update if we haven't checked in the last 24 hours
				// Or if we're forcing a check
				if (forceCheck || DateTime.Now - TimeSpan.FromHours(24) > _Settings.LastUpdateCheck)
				{
					this.latestVersionInfo = VersionChecker.GetLatestVersion();
					_Settings.LastUpdateCheck = DateTime.Now;

					Version currentVersion = a.GetName().Version;
					if (latestVersionInfo.IsVersionValid && latestVersionInfo.IsNewerThan(currentVersion))
						_Settings.UpdateAvailable = true;

					if (forceCheck)
						wMessageBox.Show(String.Format("Your version: {0}{2}Latest version: {1}", currentVersion, latestVersionInfo.Version, System.Environment.NewLine), "Version info", MessageBoxButton.OK, MessageBoxImage.Information);

					_Settings.Save();
				}

				if (_Settings.UpdateAvailable)
				{
					iUpdate.Dispatcher.BeginInvoke((Action)(() => iUpdate.Visibility = miDownload.Visibility = System.Windows.Visibility.Visible));
					iUpdate.Dispatcher.BeginInvoke((Action)(() => iUpdate.ToolTip = miDownload.ToolTip = "Update available"));
				}
			}
		}
开发者ID:micahpaul,项目名称:dominion_net_multi,代码行数:52,代码来源:wMain.xaml.cs

示例11: RunUpdater

        private void RunUpdater()
        {
            System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
            xmlDoc.Load(currentFolder + System.IO.Path.DirectorySeparatorChar + "Update" + Path.DirectorySeparatorChar + "updater.xml");

            System.Xml.XmlNodeList updaterFile = xmlDoc.GetElementsByTagName("file");
            System.Net.WebClient webClient = new System.Net.WebClient();

            webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(webClient_DownloadFileCompleted);

            string f = System.IO.Path.GetFileName(updaterFile[0].InnerText);

            if (File.Exists(currentFolder + System.IO.Path.DirectorySeparatorChar + "Update" + Path.DirectorySeparatorChar + f))
                File.Delete(currentFolder + System.IO.Path.DirectorySeparatorChar + "Update" + Path.DirectorySeparatorChar + f);

            Uri uri = new Uri(updaterFile[0].InnerText);

            string localFile = Path.GetFileName(uri.ToString());

            webClient.DownloadFileAsync(uri, currentFolder + System.IO.Path.DirectorySeparatorChar + "Update" + Path.DirectorySeparatorChar + localFile);
        }
开发者ID:nicholatian,项目名称:monody,代码行数:21,代码来源:FormMain.cs

示例12: ProgressForm_Load

 private void ProgressForm_Load(object sender, EventArgs e)
 {
     if (file != "")
     {
         try
         {
             System.Net.WebClient webClient = new System.Net.WebClient();
             webClient.DownloadProgressChanged += new System.Net.DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
             webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(webClient_DownloadFileCompleted);
             webClient.DownloadFileAsync(new System.Uri(file), localFile);
         }
         catch
         {
             MessageBox.Show("No internet connection could be established. Downloading \"" + file + "\" failed.");
         }
     }
 }
开发者ID:awesomist,项目名称:mcsLaunch,代码行数:17,代码来源:ProgressForm.cs

示例13: buttonDownload_Click

        private void buttonDownload_Click(object sender, EventArgs e)
        {
            //download the files in the File List box
            //check to make sure icechat 9 is not running
            Process[] pArry = Process.GetProcesses();

            foreach (Process p in pArry)
            {
                string s = p.ProcessName;
                s = s.ToLower();
                //System.Diagnostics.Debug.WriteLine(s);

                if (s.Equals("icechat2009"))
                {
                    System.Diagnostics.Debug.WriteLine(Path.GetDirectoryName(p.Modules[0].FileName).ToLower() + ":" + currentFolder.ToLower());
                    if (Path.GetDirectoryName(p.Modules[0].FileName).ToLower() == currentFolder.ToLower())
                    {
                        MessageBox.Show("Please Close IceChat 9 before updating.");
                        return;
                    }
               }
            }
            //MessageBox.Show("no match");
            //return;

            webClient = new System.Net.WebClient();
            this.Cursor = Cursors.WaitCursor;

            this.labelSize.Visible = true;
            this.progressBar.Visible = true;

            this.buttonDownload.Enabled = false;
            //System.Collections.ArrayList localFiles = new System.Collections.ArrayList();

            webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(webClient_DownloadFileCompleted);
            webClient.DownloadProgressChanged += new System.Net.DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);

            foreach (DownloadItem item in listFiles.Items)
            {
                //if (item.FileType == "core")
                {
                    string f = System.IO.Path.GetFileName(item.FileName);

                    //delete any previous downloaded versions of the file
                    try
                    {
                        if (File.Exists(Application.StartupPath + System.IO.Path.DirectorySeparatorChar + f))
                            File.Delete(Application.StartupPath + System.IO.Path.DirectorySeparatorChar + f);
                    }
                    catch (Exception) { }

                    System.Diagnostics.Debug.WriteLine("core:" + item.FileName);

                    Uri uri = new Uri(item.FileName);

                    localFiles.Push(uri);
                    moveFiles.Push(uri);
                }
            }

            Uri u = localFiles.Pop();
            string localFile = Path.GetFileName(u.ToString());
            currentFile = u.ToString();
            labelCurrentFile.Text = currentFile;

            webClient.DownloadFileAsync(u, Application.StartupPath + System.IO.Path.DirectorySeparatorChar + localFile);
        }
开发者ID:nicholatian,项目名称:monody,代码行数:67,代码来源:FormUpdater.cs

示例14: BeginDownload

        private static void BeginDownload(string remoteUrl, string downloadToPath, string version, string executeTarget)
        {
            var filePath = Versions.CreateTargetLocation(downloadToPath, version);

            filePath = Path.Combine(filePath, executeTarget);

            var remoteUri = new Uri(remoteUrl);
            var downloader = new System.Net.WebClient();

            downloader.DownloadFileCompleted += downloader_DownloadFileCompleted;

            downloader.DownloadFileAsync(remoteUri, filePath,
                new[] { version, downloadToPath, executeTarget });
        }
开发者ID:jdpillon,项目名称:ArduinoLadder,代码行数:14,代码来源:UpdateHelper.cs

示例15: save_Click

        private void save_Click(object sender, EventArgs e)
        {
            if (download.Checked)
            {
                if (!System.IO.Directory.Exists(path.Text))
                {
                    System.IO.Directory.CreateDirectory(path.Text);
                }
                progressBar = new SubForms.Downloading();
                System.Net.WebClient client = new System.Net.WebClient();
                client.DownloadFileAsync(new Uri("http://media.steampowered.com/client/steamcmd_win32.zip"), path.Text + @"\steamcmd.zip");
                client.DownloadFileCompleted += new AsyncCompletedEventHandler(downloadFinished);
                client.DownloadProgressChanged += new System.Net.DownloadProgressChangedEventHandler(downloadProgress);
                progressBar.Show();
            }
            else
            {
                caller.steamCmd = path.Text + @"\steamcmd.exe";

                RegistryKey rkSrcdsManager = Registry.CurrentUser.OpenSubKey("Software\\SrcdsManager", true);
                rkSrcdsManager.SetValue("steamcmd", caller.steamCmd);

                this.Dispose();
            }
        }
开发者ID:meev,项目名称:SRCDS-Manager,代码行数:25,代码来源:SteamCmd.cs


注:本文中的System.Net.WebClient.DownloadFileAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。