ASP VB.NET 下载服务器文件到客户端

来源:互联网 发布:oracle 全文检索 优化 编辑:程序博客网 时间:2024/04/28 13:37


      Try
            Dim Path As String = Server.MapPath("~/Download/") '文件路径
            Path = Path & "file.txt" '文件的名称
            If Not System.IO.File.Exists(Path) Then
                 ‘如果文件不存在
                Exit Sub
            Else
                Response.ContentType = "application/x-zip-compressed"
                Response.AddHeader("Content-Disposition", "attachment;filename=" + Server.UrlPathEncode(Path))
                Response.TransmitFile(Path)
            End If
      Catch ex As Exception
            '文件下载失败!

      End Try

原创粉丝点击