xaml采用linkbutton 其navigateuri属性链接到服务端下载的ashx文档 如 HyperlinkButton Margin="32,135,198,140" Content="HyperlinkButton" NavigateUri="http://localhost:1399/download.ashx" / download.ashx 如下 Code 1 Imports System.Web 2 Imports
xaml采用linkbutton 其navigateuri属性链接到服务端下载的ashx文档
如
download.ashx如下
doxygen是一款好用的程序员辅助工具,它可以让程序添加批添代码更加简单轻松,兼容C++、 C、Java、 Objective-C、Python等主流编程语言,小编提供的doxygen中文手册包含了基本介绍、语法技巧以及进阶技巧等内容,可以让你快速上手操作,有需要的欢迎下载。 基本介绍 Doxygen已经支持生成ANSI编码的chm目录文件(index.hhc)!Doxygen通常是用作生成英文文档的,生成中文文档需要修改输入和输出的码制,这样可以改变解析方式,生成中文文档。但是,你必须意识 到,Dox
0

Code
1
Imports System.Web
2
Imports System.Web.Services
3
Imports System.Net
4
Public Class downloadClass download
5
Implements System.Web.IHttpHandler
6
7
Private ChunkSize As Long = 102400 '100K 每次读取文件,只读取100K,这样可以缓解服务器的压力
8
9
Sub ProcessRequest()Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
10
Dim fileName As String = "aaa.JPG" '客户端保存的文件名
11
Dim filePath As String = context.Server.MapPath("image/IMG_1370.JPG") '路径
12
13
Dim fileInfo As System.IO.FileInfo = New System.IO.FileInfo(filePath)
14
15
If fileInfo.Exists = True Then
16
17
Dim buffer(ChunkSize) As Byte
18
19
context.Response.Clear()
20
Dim iStream As System.IO.FileStream = System.IO.File.OpenRead(filePath)
21
Dim dataLengthToRead As Long = iStream.Length '获取下载的文件总大小
22
23
context.Response.ContentType = "application/octet-stream"
24
'通知浏览器下载文件而不是打开
25
context.Response.AddHeader("Content-Disposition", "attachment; filename=" & _
26
HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8))
27
Loop1:
28
While dataLengthToRead > 0 And context.Response.IsClientConnected
29
Dim lengthRead As Integer = iStream.Read(buffer, 0, Convert.ToInt32(ChunkSize)) '读取的大小
30
context.Response.OutputStream.Write(buffer, 0, lengthRead)
31
context.Response.Flush()
32
dataLengthToRead = dataLengthToRead - lengthRead
33
End While
34
35
context.Response.Close()
36
context.Response.End()
37
End If
38
39
'context.Response.ContentType = "text/plain"
40
'context.Response.Write("Hello World!")
41
42
End Sub
43
44
ReadOnly Property IsReusable()Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
45
Get
46
Return False
47
End Get
48
End Property
49
50
End Class
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号