How can i check if file download completed ?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I want to make a check IF the file download is completed then do something...<br/>for example in this code i want to make that when the file download is complete turn on the download button to TRUE again .<br/><br/>I did that after you press the download button is false the button . Now i want that if the download is completed make the download button true again .<br/><br/><span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small <font size=2 color="#0000ff <font size=2 color="#0000ff
using
</font></font><font size=2 color="#0000ff

</font>
<span style="font-size:x-small System;
<span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small <font size=2 color="#0000ff <font size=2 color="#0000ff
using
</font></font><font size=2 color="#0000ff

</font>
<span style="font-size:x-small System.Collections.Generic;
<span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small <font size=2 color="#0000ff <font size=2 color="#0000ff
using
</font></font><font size=2 color="#0000ff

</font>
<span style="font-size:x-small System.ComponentModel;
<span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small <font size=2 color="#0000ff <font size=2 color="#0000ff
using
</font></font><font size=2 color="#0000ff

</font>
<span style="font-size:x-small System.Data;
<span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small <font size=2 color="#0000ff <font size=2 color="#0000ff
using
</font></font><font size=2 color="#0000ff

</font>
<span style="font-size:x-small System.Drawing;
<span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small <font size=2 color="#0000ff <font size=2 color="#0000ff
using
</font></font><font size=2 color="#0000ff

</font>
<span style="font-size:x-small System.Linq;
<span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small <font size=2 color="#0000ff <font size=2 color="#0000ff
using
</font></font><font size=2 color="#0000ff

</font>
<span style="font-size:x-small System.Text;
<span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small <font size=2 color="#0000ff <font size=2 color="#0000ff
using
</font></font><font size=2 color="#0000ff

</font>
<span style="font-size:x-small System.Windows.Forms;
<span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small <font size=2 color="#0000ff <font size=2 color="#0000ff
using
</font></font><font size=2 color="#0000ff

</font>
<span style="font-size:x-small System.Net;
<span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small <font size=2 color="#0000ff <font size=2 color="#0000ff
using
</font></font><font size=2 color="#0000ff

</font>
<span style="font-size:x-small System.IO;
<span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small <font size=2 color="#0000ff <font size=2 color="#0000ff
namespace
</font></font><font size=2 color="#0000ff

</font>
<span style="font-size:x-small WindowsFormsApplication1
{
<font size=2>

</font>
<span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small public<span style="font-size:x-small <span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small partial<span style="font-size:x-small <span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small class<span style="font-size:x-small <span style="color:#2b91af;font-size:x-small <span style="color:#2b91af;font-size:x-small Form1<span style="font-size:x-small : <span style="color:#2b91af;font-size:x-small <span style="color:#2b91af;font-size:x-small Form
<span style="font-size:x-small
{
<font size=2>

</font>
<span style="color:#2b91af;font-size:x-small <span style="color:#2b91af;font-size:x-small WebClient<span style="font-size:x-small Client = <span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small new<span style="font-size:x-small <span style="color:#2b91af;font-size:x-small <span style="color:#2b91af;font-size:x-small WebClient<span style="font-size:x-small ();<font size=2>

</font>
<span style="color:#2b91af;font-size:x-small <span style="color:#2b91af;font-size:x-small ProgressBar<span style="font-size:x-small prgBar = <span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small new<span style="font-size:x-small <span style="color:#2b91af;font-size:x-small <span style="color:#2b91af;font-size:x-small ProgressBar<span style="font-size:x-small ();<font size=2>

</font>
<span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small public<span style="font-size:x-small Form1()
{
InitializeComponent();

}
<font size=2>

</font>
<span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small private<span style="font-size:x-small <span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small void<span style="font-size:x-small button1_Click(<span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small object<span style="font-size:x-small sender, <span style="color:#2b91af;font-size:x-small <span style="color:#2b91af;font-size:x-small EventArgs<span style="font-size:x-small e)
{
<font size=2>

</font>
<span style="color:#2b91af;font-size:x-small <span style="color:#2b91af;font-size:x-small Stream<span style="font-size:x-small strm = Client.OpenRead(<span style="color:#a31515;font-size:x-small <span style="color:#a31515;font-size:x-small "http://www.ims.gov.il/Ims/Pages/RadarImage.aspx?Row=9&TotalImages=10&LangID=1&Location="<span style="font-size:x-small );<font size=2>

</font>
<span style="color:#2b91af;font-size:x-small <span style="color:#2b91af;font-size:x-small StreamReader<span style="font-size:x-small sr = <span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small new<span style="font-size:x-small <span style="color:#2b91af;font-size:x-small <span style="color:#2b91af;font-size:x-small StreamReader<span style="font-size:x-small (strm);<font size=2>
Client.DownloadFile(
</font>
<span style="color:#a31515;font-size:x-small <span style="color:#a31515;font-size:x-small "http://www.ims.gov.il/Ims/Pages/RadarImage.aspx?Row=9&TotalImages=10&LangID=1&Location="<span style="font-size:x-small , <span style="color:#a31515;font-size:x-small <span style="color:#a31515;font-size:x-small @"d:testfileuntitled.bmp"<span style="font-size:x-small );

progressBar1.Maximum = 10;
progressBar1.Minimum = 0;
progressBar1.TabIndex = 0;
progressBar1.Value = 0;
progressBar1.Step = 10;
progressBar1.PerformStep();
<font size=2>
button1.Enabled =
</font>
<span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small false<span style="font-size:x-small ;
sr.Close();
strm.Close();
strm.Flush();


}

<font size=2>

</font>
<span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small private<span style="font-size:x-small <span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small void<span style="font-size:x-small progressBar1_Click(<span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small object<span style="font-size:x-small sender, <span style="color:#2b91af;font-size:x-small <span style="color:#2b91af;font-size:x-small EventArgs<span style="font-size:x-small e)
{

}
<font size=2>

</font>
<span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small private<span style="font-size:x-small <span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small void<span style="font-size:x-small button2_Click(<span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small object<span style="font-size:x-small sender, <span style="color:#2b91af;font-size:x-small <span style="color:#2b91af;font-size:x-small EventArgs<span style="font-size:x-small e)
{
<font size=2>

</font>
<span style="color:#2b91af;font-size:x-small <span style="color:#2b91af;font-size:x-small FileInfo<span style="font-size:x-small MyFile = <span style="color:#0000ff;font-size:x-small <span style="color:#0000ff;font-size:x-small new<span style="font-size:x-small <span style="color:#2b91af;font-size:x-small <span style="color:#2b91af;font-size:x-small FileInfo<span style="font-size:x-small (<span style="color:#a31515;font-size:x-small <span style="color:#a31515;font-size:x-small @"d:testfileuntitled.bmp"<span style="font-size:x-small );
MyFile.Delete();


}

}
}<br/><br/><br/><br/>I want to check using IF () the file download is completed and only when the file is completed do something in the if function .<br/>And if there is a way to turn the download button to true again after download is completed without using if () please show me too .<br/><br/>Show me both option with If() and without .<br/><br/><br/>Thanks .
<hr class="sig danieli

View the full article
 
Back
Top