wait for webrequest to finish
<p>hi this function downloads an image from source and adds it to a zip file.
the problem is sometimes the image comes out all messed up(1/3 is downloaded, the rest is empty space) as if the download isn't finish. how can i make sure the download is finished before i move on? thank you.</p>

<p>edit: i have timeout there so it wouldnt wait indefinitely. should i just extend the timeout? or is there a better way?</p>

<pre><code>public void addImage(string source, string destination)
    {
        if (isFinalized)
            return;

        try
        {
            WebRequest req = WebRequest.Create(source);
            req.Timeout = 5000;

            WebResponse resp = req.GetResponse();
            BufferedStream reader = new BufferedStream(resp.GetResponseStream());

            byte[] fileData = new byte[resp.ContentLength];
            reader.Read(fileData, 0, fileData.Length);
            zip.AddEntry(destination, fileData);
        }
        catch (Exception exp)
        {
        }
    }
</code></pre>
