I am performing several httpwebrequest and webresponse operations to download some wav files.
I included the sample code below. When I execute these commands they work for a while and then
5 - 50 minutes into doing its thing i will start to get errors like:
System.Net.WebException: The operation has timed-out
My function I call is GetWaveFile(Wav9,"Wav9",sFileName);
it is in a service that grabs a different wav file every 5 seconds, and the full code is below:
I do close the response below, but not quite sure whats going on, and its really boggling me.
public static void GetWaveFile(string sURL, string sType, string sFileName)
{
HttpWebRequest HttpWReq =
(HttpWebRequest)WebRequest.Create(sURL);
HttpWReq.Method = "GET";
HttpWebResponse HttpWResponse = (HttpWebResponse)HttpWReq.GetResponse();
StreamReader sr = new StreamReader(HttpWResponse.GetResponseStream());
FileStream fs = new FileStream("d:/Files/" + sType + sFileName + ".wav",System.IO.FileMode.Create);
BinaryWriter w = new BinaryWriter(fs);
BinaryReader r = new BinaryReader(sr.BaseStream);
byte[] data = r.ReadBytes(300000);
w.Write(data);
HttpWResponse.Close();
}