coldfusion244
Junior Contributor
I found some code for downloading the contents of a webpage, and it works great...in everything but XP SP2. For some reason it always throws an exception.
[CS]
public class CSDownloadURL
{
private string m_strURL;
public void setURL1( string strURL )
{
m_strURL = strURL;
}
public void DownloadURL(out string strContents)
{
WebRequest req = WebRequest.Create(m_strURL);
WebResponse res = req.GetResponse();
int iTotalBuff = 0;
Byte[] Buffer = new Byte[128];
Stream stream = res.GetResponseStream();
iTotalBuff = stream.Read(Buffer, 0, 128);
StringBuilder strRes = new StringBuilder("");
while(iTotalBuff != 0)
{
strRes.Append(Encoding.ASCII.GetString(Buffer, 0, iTotalBuff));
iTotalBuff = stream.Read(Buffer, 0, 128);
}
strContents = strRes.ToString();
}
}
[/CS]
Why would it work fine in everything but XP SP2 and windows 2003 server?
[CS]
public class CSDownloadURL
{
private string m_strURL;
public void setURL1( string strURL )
{
m_strURL = strURL;
}
public void DownloadURL(out string strContents)
{
WebRequest req = WebRequest.Create(m_strURL);
WebResponse res = req.GetResponse();
int iTotalBuff = 0;
Byte[] Buffer = new Byte[128];
Stream stream = res.GetResponseStream();
iTotalBuff = stream.Read(Buffer, 0, 128);
StringBuilder strRes = new StringBuilder("");
while(iTotalBuff != 0)
{
strRes.Append(Encoding.ASCII.GetString(Buffer, 0, iTotalBuff));
iTotalBuff = stream.Read(Buffer, 0, 128);
}
strContents = strRes.ToString();
}
}
[/CS]
Why would it work fine in everything but XP SP2 and windows 2003 server?