Click here to Skip to main content
15,899,754 members
Home / Discussions / C#
   

C#

 
AnswerRe: how can recognize file extension for download Pin
B.A3-Feb-07 5:24
B.A3-Feb-07 5:24 
GeneralRe: how can recognize file extension for download Pin
Rizawn4-Feb-07 1:16
Rizawn4-Feb-07 1:16 
JokeRe: how can recognize file extension for download Pin
B.A4-Feb-07 3:50
B.A4-Feb-07 3:50 
GeneralRe: how can recognize file extension for download Pin
VirtualVoid.NET6-Feb-07 3:53
VirtualVoid.NET6-Feb-07 3:53 
QuestionThread confusion !! Pin
Hussam Fattahi3-Feb-07 3:30
Hussam Fattahi3-Feb-07 3:30 
AnswerRe: Thread confusion !! Pin
Guffa3-Feb-07 3:57
Guffa3-Feb-07 3:57 
QuestionWebClient And ProgressBar Pin
Rizawn3-Feb-07 2:52
Rizawn3-Feb-07 2:52 
AnswerRe: WebClient And ProgressBar Pin
B.A3-Feb-07 4:12
B.A3-Feb-07 4:12 
hi , you can use this code ...
but befor i put code , i have a question :
for download , how can recognize the file extention ?

--------------------------------------------------------------
you can use "Download Progress Indicator Technology Sample "
topic in msdn


--------------------------------------------------------------
code
--------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;

namespace downloadManager
{
public partial class Form1 : Form
{
private bool isBusy;
private WebClient client;

public Form1()
{
InitializeComponent();
client = new WebClient();

// Wire up the download complete event handler.
// The operation will either complete successfully or with an
// error code.
client.DownloadFileCompleted += client_DownloadFileCompleted;
// Wire up the download progress event handler.
client.DownloadProgressChanged += client_DownloadProgressChanged;
}

private void button1_Click(object sender, EventArgs e)
{
// If an operation is pending, then the user has clicked cancel.
if (isBusy)
{
client.CancelAsync();
isBusy = false;
this.downloadButton.Text = "Download";
}
// Otherwise go ahead and start the download
else
{
try
{
Uri uri = new Uri(urlTextBox.Text);
string fileName = System.IO.Path.GetFileName(urlTextBox.Text);
string fileExtention = System.IO.Path.GetExtension(urlTextBox.Text);
string downloadString = client.DownloadString(uri);
this.toolStripProgressBar1.Value = 0;
client.DownloadFileAsync(uri, "test");
this.downloadButton.Text = "Cancel";
isBusy = true;
}
catch (UriFormatException ex)
{
MessageBox.Show(ex.Message);
}
}
}

// Displays a message indicating that the download completed
// successfully, or if there was an error it will be displayed instead.
private void client_DownloadFileCompleted(
object sender, AsyncCompletedEventArgs e)
{
isBusy = false;
this.downloadButton.Text = "Download";
if (e.Error == null)
{
MessageBox.Show("Download Complete");
}
else
MessageBox.Show("Download Not Complete: " + e.Error.Message);
this.toolStripProgressBar1.Value = 0;
}

// Updates the progress indicator with the latest progress
private void client_DownloadProgressChanged(
object sender, DownloadProgressChangedEventArgs e)
{
this.toolStripProgressBar1.Value = e.ProgressPercentage;
}

}
}
GeneralRe: WebClient And ProgressBar Pin
Rizawn3-Feb-07 4:26
Rizawn3-Feb-07 4:26 
QuestionVIDEO WATERMARKING Pin
PREDATORUNLEASHED2-Feb-07 21:49
PREDATORUNLEASHED2-Feb-07 21:49 
AnswerRe: VIDEO WATERMARKING Pin
Christian Graus2-Feb-07 21:57
protectorChristian Graus2-Feb-07 21:57 
Questionhelp for Remember Password Pin
Nekshan2-Feb-07 20:57
Nekshan2-Feb-07 20:57 
AnswerRe: help for Remember Password Pin
quiteSmart2-Feb-07 21:14
quiteSmart2-Feb-07 21:14 
GeneralRe: help for Remember Password Pin
echuck663-Feb-07 16:02
echuck663-Feb-07 16:02 
GeneralThank You QuiteSmart, but... Pin
Nekshan4-Feb-07 23:49
Nekshan4-Feb-07 23:49 
AnswerRe: help for Remember Password Pin
echuck663-Feb-07 16:00
echuck663-Feb-07 16:00 
QuestionInternal Chat Pin
drc_no12-Feb-07 20:34
drc_no12-Feb-07 20:34 
QuestionHow to access .hlp file in C#.Net Pin
sjs4u2-Feb-07 20:26
sjs4u2-Feb-07 20:26 
AnswerRe: How to access .hlp file in C#.Net Pin
Mircea Puiu2-Feb-07 21:27
Mircea Puiu2-Feb-07 21:27 
GeneralRe: How to access .hlp file in C#.Net Pin
sjs4u2-Feb-07 22:44
sjs4u2-Feb-07 22:44 
QuestionStart/stop button Pin
Rapier5032-Feb-07 19:57
Rapier5032-Feb-07 19:57 
AnswerRe: Start/stop button Pin
drc_no12-Feb-07 20:11
drc_no12-Feb-07 20:11 
GeneralRe: Start/stop button Pin
Rapier5032-Feb-07 20:25
Rapier5032-Feb-07 20:25 
AnswerRe: Start/stop button Pin
quiteSmart2-Feb-07 20:21
quiteSmart2-Feb-07 20:21 
AnswerRe: Start/stop button Pin
Mircea Puiu2-Feb-07 21:22
Mircea Puiu2-Feb-07 21:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.