Downloading File Using C#
Downloading File Using C#
Welcome, you are an anonymous user! [register] [login] Get a [email protected] email address
Geek Reverser
View Solutions
Test Centre
Mau Ke Luar Angkasa ?
Hall of Brain www.axeapollo.co.id
Hall of Bonus Tinggal Hari Ini Kesempatan Lo Bisa Pergi Ke Luar Angkasa Sob. Buruan!
Hall of
Reverse Program will download file every n minutes and save it to specified folder. So you can basically grab web cam pictures and make nice looking time line.
Geek or Freak
Lets make couple of TextBox and NumericUpDown control for time. Something like Start button and browse folder button is also needed. I dont like user to type paths so we disabled the folder edit box.
Forgot
password? We also needed to timer control and folderBrowserDialog. Some kind of user check input is required. We make simple test to see if there is URL and Folder boxes text. If there are we can enable start button.
New account
When user fill the form and press start button some kind feedback would be nice. So lets change the text to Stop, and start downloading file. Timer uses milliseconds so we need to convert minutes to milliseconds. When timer is started it waits specified time and then calls the tick routine. This isn't good, pressing start and wait just like local bank. So we call download
Shoutbox routine one time before we start waiting timer event.
MaxMouse
It's Friday... Lets download the file and save it. Save it with what name? Lets use time stamp. After quick search in Google we notice that default time format is 10/12/2002 10:11 PM and there is group of time formats that are near of this. Now this isnt good because we cannot use / and : charters in filenames.
That's good
enough for me! So we need to build date string. Lets use European style date dd.MM.YYYY and put dot in the time format. We dont need seconds here so we can drop them off. After quick test I noticed that filename extension is missing so computer doesnt understand picture files. Picture files can be in several formats and if user wants to download other files than pictures we need to
CodeX know the extension. Lets parse the URL to get the extension we need.
non stop lolz
here but thats After downloading couple of files I noticed that the program actually stops when the file has been downloaded. I used DownloadFile() method for this. So the program actually stops that time when file is downloaded. Wrong method call, asynchronous is magic word. So we need to use DownloadFileAsync() method.
soon to end
thanks to uni, using System;
using System.Collections.Generic;
surely the rest
using System.ComponentModel;
of the world is
using System.Data;
going good? using System.Drawing;
stabat using System.Text;
how things are using System.Windows.Forms;
going guys? using System.IO;
Here... using System.Net;
boring...
CodeX namespace TimeDL
I must be {
going wrong on public partial class Form1 : Form
the password {
bool dl = false;
lengths then,
as long as it
public Form1()
was done on {
ECB InitializeComponent();
MaxMouse }
lol... the key is
in hex (MD5: private void button2_Click(object sender, EventArgs e)
of the string {
"doit" without folderBrowserDialog1.ShowDialog();
the "'s) and is textBoxFolder.Text = folderBrowserDialog1.SelectedPath;
in lower case. }
Maybe i should
private void textBoxURL_TextChanged(object sender, EventArgs e)
have
{
submitted this if (textBoxURL.Text.Length > 0 && textBoxFolder.Text.Length > 0)
as a challenge! button1.Enabled = true;
}
Donate
Donate and help private void textBoxFolder_TextChanged(object sender, EventArgs e)
us fund new {
challenges if (textBoxURL.Text.Length > 0 && textBoxFolder.Text.Length > 0)
button1.Enabled = true;
}
Due Date: Sep 30 private void button1_Click(object sender, EventArgs e)
September {
Goal:
$40.00
if (dl == false)
Gro ss: $0.00 {
Net button1.Text = "Stop";
Balance: $0.00 timer1.Interval = Convert.ToInt32(numericUpDownInterval.Value) * 1000 * 60;
Le ft to go: $40.00 timer1_Tick(null, null);
timer1.Start();
Contributors dl = true;
}
else
{
News Feeds button1.Text = "Start";
The Register timer1.Stop();
Memory muddle dl = false;
muddies Intel"s }
Exascale ambitions }
Microsoft reissues
September patches private void timer1_Tick(object sender, EventArgs e)
after user {
complaints string stamp;
DateTime CurrTime = DateTime.Now;
1 of 2 9/15/2013 10:53 AM
Downloading file using C# - This article explains how to make simple program that will download file every n minutes and save it to specified fold... http://www.osix.net/modules/article/?id=875
BB Code is enabled.
Captcha Number:
bb ASP.NET RadioButton GroupName when inside a Repeater on Sun 10th Jun 8am
I was thankful on finding this nugget of code, which makes the groupname work out when slamming in radiobuttons in an asp.net repeater. http://www.codeguru.com/csharp/csharp/cs _controls/custom/article.php/c12371/
Your Ad Here
2 of 2 9/15/2013 10:53 AM