Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. c# code for downloading a video file and saving it

c# code for downloading a video file and saving it

Scheduled Pinned Locked Moved ASP.NET
csharpasp-net
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sarodam
    wrote on last edited by
    #1

    a user have logged into a website having video files. He when clicks the download button a dialog box should open asking where the video file should be saved.when he gives a path it should start downloading...hw to code it in c# .i am using asp.net 2.0..

    V 1 Reply Last reply
    0
    • S sarodam

      a user have logged into a website having video files. He when clicks the download button a dialog box should open asking where the video file should be saved.when he gives a path it should start downloading...hw to code it in c# .i am using asp.net 2.0..

      V Offline
      V Offline
      varshavmane
      wrote on last edited by
      #2

      Try this but sorry its in VB: Dim strFolderPath As String = AppDomain.CurrentDomain.BaseDirectory() & "02\TMCoverageArea\" Dim strFilePath As String strFilePath = strFolderPath & hlkCoverageArea.Text DownloadFile(strFilePath, True) Private Sub DownloadFile(ByVal FilePath As String, ByVal ForceToDownload As Boolean) 'Dim path As Path Dim strFullFilePath = IO.Path.GetFullPath(FilePath) Dim strFileName = IO.Path.GetFileName(strFullFilePath) Dim strExtension = IO.Path.GetExtension(strFullFilePath) Dim strFileType As String = "" If Not IsDBNull(strExtension) Then strExtension = LCase(strExtension) End If strFileType = GetFileTypeFromExtension(strExtension) If (ForceToDownload) Then Response.AppendHeader("content-disposition", _ "attachment; filename=" + strFileName) End If If strFileType <> "" Then Response.ContentType = strFileType End If Response.WriteFile(strFullFilePath) Response.End() End Sub Public Function GetFileTypeFromExtension(ByVal FileExtension As String) As String Try Dim strFileType As String = "" Select Case FileExtension Case ".htm", ".html" strFileType = "text/HTML" Case ".txt" strFileType = "text/plain" Case ".doc", ".rtf" strFileType = "Application/msword" Case ".csv", ".xls" strFileType = "Application/x-msexcel" Case Else strFileType = "text/plain" End Select Return strFileType Catch ex As Exception End Try End Function

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups