Hi I am unable to download an audio file from a streaming server. The audio is downloading but only 388 bytes is showing.Can you help to resolve the problem. Thanks in advance.
My code is as follows:
string strExt, audiofile, mpg;
strExt = rdoformats.SelectedValue.ToString();
audiofile = Session["audio_name"].ToString();
int j = audiofile.LastIndexOf(".");
mpg = audiofile.Remove(j);
mpg = mpg + strExt;
string url = string.Empty;
if (url == null || url.Length == 0)
{
url = "http://path/oflaDemo/";
}
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
int bufferSize = 1;
Response.Clear();
Response.AppendHeader("Content-Disposition:", "attachment; filename=" + mpg);
Response.AppendHeader("Content-Length", resp.ContentLength.ToString());
Response.ContentType = "application/download";
byte[] ByteBuffer = new byte[bufferSize + 1];
MemoryStream ms = new MemoryStream(ByteBuffer, true);
// Stream rs = req.GetResponse().GetResponseStream();
Stream rs = resp.GetResponseStream();
byte[] bytes = new byte[bufferSize + 1];
while (rs.Read(ByteBuffer, 0, ByteBuffer.Length) > 0)
{
Response.BinaryWrite(ms.ToArray());
Response.Flush();
}
Response.End();
ms.Close();
ms.Dispose();
rs.Dispose();
ByteBuffer = null;