By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,986 Members | 2,086 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,986 IT Pros & Developers. It's quick & easy.

Using ASP page to download .wmv file

P: n/a
RJT
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.
Nov 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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" <rj*@noemail.com> wrote in message
news:cs*********@news1.newsguy.com...
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.

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.