What is wrong with this code?
There is a huge bug in this code, resulting in data corruption. Can you spot what it is?
public byte[] DownloadBytes(string url, ICredentials credentials) { WebRequest request = Util.SetupWebRequest(WebRequest.Create(url), credentials); using (WebResponse response = request.GetResponse()) { using (Stream stream = GetResponseStream(response)) { byte[] buffer = new byte[response.ContentLength]; int current = 0; int read; do { read = stream.Read(buffer, current, buffer.Length - current); current += read; } while (read != 0); return buffer; } } }
Hint, this has nothing to do with exception handling. Assumes that nothing goes wrong.

Comments
Comment preview