here is the code for downloading any file from the specified location using the file stream.. Please refer the code for the same..
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim root As String = "C:\Inetpub\wwwroot\Test\"
Dim filepath As String = "C:\Inetpub\wwwroot\Test\Test.2.zip"
If File.Exists(filepath) And filepath.StartsWith(root) Then
Dim filename As String = Path.GetFileName(filepath)
Response.Clear()
Response.ContentType = "application/octet-stream"
Response.AddHeader("Content-Disposition", "attachment; filename=""" & filename & """")
Response.Flush()
Response.WriteFile(filepath)
End If
End Sub
Dim root As String = "C:\Inetpub\wwwroot\Test\"
Dim filepath As String = "C:\Inetpub\wwwroot\Test\Test.2.zip"
If File.Exists(filepath) And filepath.StartsWith(root) Then
Dim filename As String = Path.GetFileName(filepath)
Response.Clear()
Response.ContentType = "application/octet-stream"
Response.AddHeader("Content-Disposition", "attachment; filename=""" & filename & """")
Response.Flush()
Response.WriteFile(filepath)
End If
End Sub
ThanksAnil Kumar PandeySystem Architect, MVPMumbai, Maharshtra
ty
ReplyDelete