Connecting Tech Pros Worldwide Help | Site Map

Using ASP page to download .wmv file

RJT
Guest
 
Posts: n/a
#1: Nov 19 '05
I want to set up an asp page that will download a .wmv (Windows Media video)
file to the user and save it in a directory of the user's choice on the
user's computer. I think this is an elementary situation using
Response.ContentType, and the MIME type for a .wmv file, but I don't know
exactly how.

Thanks very much for any help.


Daniel Fisher\(lennybacon\)
Guest
 
Posts: n/a
#2: Nov 19 '05

re: Using ASP page to download .wmv file


Response.Clear();
Response.ContentType = "video/x-ms-wmv";
Response.AddHeader("Content-Disposition", "attachment; filename=" +
Path.GetFileName(_filePath));
Response.AddHeader("Content-Length", new
FileInfo(_filePath).Length.ToString());

Response.Buffer = false;
FileStream _fileStream = null;
byte[] _buffer = new byte[this.m_bufferSize];
long _byteCount;
try
{
_fileStream = File.OpenRead(_filePath);
while ((_byteCount = _fileStream.Read(_buffer, 0, _buffer.Length)) > 0)
{
if(Response.IsClientConnected)
{
Response.OutputStream.Write(_buffer, 0, _buffer.Length);
Response.Flush();
}
else
{
//OnDownloadCancelled();
return;
}
}
//OnDownloadCompleted();
}
catch(Exception _ex)
{
throw _ex;
}
finally
{
_fileStream.Close();
context.Response.End();
}


--
Daniel Fisher(lennybacon)
MCP ASP.NET C#
Blog: http://www.lennybacon.com/


"RJT" <rjt@noemail.com> wrote in message
news:csc1i5025mr@news1.newsguy.com...[color=blue]
>I want to set up an asp page that will download a .wmv (Windows Media
>video)
> file to the user and save it in a directory of the user's choice on the
> user's computer. I think this is an elementary situation using
> Response.ContentType, and the MIME type for a .wmv file, but I don't know
> exactly how.
>
> Thanks very much for any help.
>
>[/color]


Closed Thread