<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://performiq.com/kb/index.php?action=history&amp;feed=atom&amp;title=Using_WebClient</id>
	<title>Using WebClient - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://performiq.com/kb/index.php?action=history&amp;feed=atom&amp;title=Using_WebClient"/>
	<link rel="alternate" type="text/html" href="https://performiq.com/kb/index.php?title=Using_WebClient&amp;action=history"/>
	<updated>2026-05-18T23:54:13Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>https://performiq.com/kb/index.php?title=Using_WebClient&amp;diff=3916&amp;oldid=prev</id>
		<title>PeterHarding: Created page with &quot;See - http://stackoverflow.com/questions/6348804/net-error-when-calling-system-net-webclient-uploadfileasync  &lt;pre&gt; var targetUri = new Uri(&quot;ftp://example.com/file.txt&quot;); var ...&quot;</title>
		<link rel="alternate" type="text/html" href="https://performiq.com/kb/index.php?title=Using_WebClient&amp;diff=3916&amp;oldid=prev"/>
		<updated>2012-11-25T21:49:00Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;See - http://stackoverflow.com/questions/6348804/net-error-when-calling-system-net-webclient-uploadfileasync  &amp;lt;pre&amp;gt; var targetUri = new Uri(&amp;quot;ftp://example.com/file.txt&amp;quot;); var ...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;See - http://stackoverflow.com/questions/6348804/net-error-when-calling-system-net-webclient-uploadfileasync&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
var targetUri = new Uri(&amp;quot;ftp://example.com/file.txt&amp;quot;);&lt;br /&gt;
var srcFile = string.Empty;  // documentation says this will throw WebException&lt;br /&gt;
var client = new WebClient();&lt;br /&gt;
client.UploadFileAsync(targetUri, &amp;quot;STOR&amp;quot;, srcFile, null);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=XtremeDotNetTalk=&lt;br /&gt;
&lt;br /&gt;
From - http://www.xtremedotnettalk.com/showthread.php?t=95893&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
string url = &amp;quot;http://localhost/images/test.jpg&amp;quot;&lt;br /&gt;
&lt;br /&gt;
// Download the file&lt;br /&gt;
// (using System.Net)&lt;br /&gt;
WebClient client = new WebClient();&lt;br /&gt;
client.Credentials = System.Net.CredentialCache.DefaultCredentials;&lt;br /&gt;
byte[] data = client.DownloadData(url);&lt;br /&gt;
&lt;br /&gt;
// write the file to the temp directory&lt;br /&gt;
// (using System.IO)&lt;br /&gt;
string path = Path.GetTempPath() + @&amp;quot;\image.jpg&amp;quot;;&lt;br /&gt;
FileStream fileStream = new FileStream(path, FileMode.Create);&lt;br /&gt;
fileStream.Write(data, 0, data.Length);&lt;br /&gt;
fileStream.Close();&lt;br /&gt;
&lt;br /&gt;
// open the file&lt;br /&gt;
// (using System.Diagnostics)&lt;br /&gt;
Process process = new Process();&lt;br /&gt;
process.StartInfo.FileName = path;&lt;br /&gt;
process.Start();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=eggheadcafe=&lt;br /&gt;
&lt;br /&gt;
From - http://www.eggheadcafe.com/community/csharp/2/10038606/webclient-throwing-exception.aspx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
private void button1_Click(object sender, EventArgs e)&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
   this.label1.Text = &amp;quot;btn1 clicked&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
   WebClient Client = new WebClient();&lt;br /&gt;
   try&lt;br /&gt;
      {&lt;br /&gt;
&lt;br /&gt;
         WebProxy proxyObject = new WebProxy(&amp;quot;http://corporate.proxy.com:8888/&amp;quot;, true);&lt;br /&gt;
         Client.Proxy = proxyObject;&lt;br /&gt;
&lt;br /&gt;
         string userName = &amp;quot;myDomain\\myUserName&amp;quot;;&lt;br /&gt;
         string password = &amp;quot;mypassword&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
         Client.Credentials = new NetworkCredential(userName, password);&lt;br /&gt;
&lt;br /&gt;
         Client.DownloadFile(&amp;quot;http://www.gutenberg.org/files/25662/25662.txt&amp;quot;, &amp;quot;c:\\temp\\myTestFile.txt&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      catch (WebException ex)&lt;br /&gt;
      {&lt;br /&gt;
         MessageBox.Show(ex.ToString());&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      catch (Exception ex)&lt;br /&gt;
      {&lt;br /&gt;
         MessageBox.Show(ex.ToString());&lt;br /&gt;
      }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Dot.NET]]&lt;/div&gt;</summary>
		<author><name>PeterHarding</name></author>
	</entry>
</feed>