Front-end code
<Embed src = "<% = VUrl %>" noerror = "true" style = "width: 579px; height: 321px"> </embed>
Background code
// Watch the video
Protected void seeVi ()
{
Try
{
String SQL = "select * from tb_Video where VideoID =" + Convert. ToInt32 (Request. QueryString ["VideoID"]);
OleDbDataReader odr = mydo. row (SQL); // call the row Method in the database operation class
Odr. Read (); // a previous record
VUrl = "Video" + "\" + odr ["VideoUrl"]. ToString (); // path for storing the Video tutorial
If (! File. Exists (Server. MapPath (".") + "\" + VUrl) // you can check whether this tutorial Exists.
{
String dlsql = "delete from tb_Video where VideoID =" + Convert. ToInt32 (Request. QueryString ["VideoID"]);
Mydo. adlData (dlsql );
Page. RegisterStartupScript ("true", "<script> alert ('the file does not exist! Please return! '); Location = 'index. aspx' </script> ");
}
VideoTitle = odr ["VideoName"]. ToString ();
Content = odr ["VideoContent"]. ToString ();
Name = odr ["Name"]. ToString ();
FBDate = odr ["FBDate"]. ToString ();
ClickSum = odr ["ClickSum"]. ToString ();
}
Catch (Exception ex)
{
Response. Write (ex. Message. ToString ());
}
}
File Download:
If (Session ["UserName"]! = Null)
{
String path = Server. MapPath (". \") + VUrl;
// Initialize the FileInfo class instance, which is packaged as the file path
FileInfo fi = new FileInfo (path );
Response. Write (path );
// Determine whether a file exists
If (fi. Exists)
{
// Save the file to the Local Machine
Response. Clear ();
Response. AddHeader ("Content-Disposition", "attachment; filename =" + Server. UrlEncode (fi. Name ));
Response. AddHeader ("Content-Length", fi. Length. ToString ());
Response. ContentType = "application/octet-stream ";
Response. Filter. Close ();
Response. WriteFile (fi. FullName );
Response. End ();
}