Home Database Mysql Tutorial SilverLight下载任意文件技巧

SilverLight下载任意文件技巧

Jun 07, 2016 pm 02:59 PM
silverlight xaml download Skill document

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如下

 

SilverLight下载任意文件技巧SilverLight下载任意文件技巧Code
 1SilverLight下载任意文件技巧Imports System.Web
 2SilverLight下载任意文件技巧Imports System.Web.Services
 3SilverLight下载任意文件技巧Imports System.Net
 4SilverLight下载任意文件技巧SilverLight下载任意文件技巧Public Class downloadClass download
 5SilverLight下载任意文件技巧    Implements System.Web.IHttpHandler
 6SilverLight下载任意文件技巧
 7SilverLight下载任意文件技巧    Private ChunkSize As Long = 102400 '100K 每次读取文件,只读取100K,这样可以缓解服务器的压力
 8SilverLight下载任意文件技巧
 9SilverLight下载任意文件技巧SilverLight下载任意文件技巧    Sub ProcessRequest()Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
10SilverLight下载任意文件技巧        Dim fileName As String = "aaa.JPG" '客户端保存的文件名
11SilverLight下载任意文件技巧        Dim filePath As String = context.Server.MapPath("image/IMG_1370.JPG"'路径
12SilverLight下载任意文件技巧
13SilverLight下载任意文件技巧        Dim fileInfo As System.IO.FileInfo = New System.IO.FileInfo(filePath)
14SilverLight下载任意文件技巧
15SilverLight下载任意文件技巧        If fileInfo.Exists = True Then
16SilverLight下载任意文件技巧
17SilverLight下载任意文件技巧            Dim buffer(ChunkSize) As Byte
18SilverLight下载任意文件技巧
19SilverLight下载任意文件技巧            context.Response.Clear()
20SilverLight下载任意文件技巧            Dim iStream As System.IO.FileStream = System.IO.File.OpenRead(filePath)
21SilverLight下载任意文件技巧            Dim dataLengthToRead As Long = iStream.Length '获取下载的文件总大小
22SilverLight下载任意文件技巧
23SilverLight下载任意文件技巧            context.Response.ContentType = "application/octet-stream"
24SilverLight下载任意文件技巧            '通知浏览器下载文件而不是打开
25SilverLight下载任意文件技巧            context.Response.AddHeader("Content-Disposition""attachment;  filename=" & _
26SilverLight下载任意文件技巧                               HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8))
27SilverLight下载任意文件技巧Loop1:
28SilverLight下载任意文件技巧            While dataLengthToRead > 0 And context.Response.IsClientConnected
29SilverLight下载任意文件技巧                Dim lengthRead As Integer = iStream.Read(buffer, 0, Convert.ToInt32(ChunkSize)) '读取的大小
30SilverLight下载任意文件技巧                context.Response.OutputStream.Write(buffer, 0, lengthRead)
31SilverLight下载任意文件技巧                context.Response.Flush()
32SilverLight下载任意文件技巧                dataLengthToRead = dataLengthToRead - lengthRead
33SilverLight下载任意文件技巧            End While
34SilverLight下载任意文件技巧  
35SilverLight下载任意文件技巧            context.Response.Close()
36SilverLight下载任意文件技巧            context.Response.End()
37SilverLight下载任意文件技巧        End If
38SilverLight下载任意文件技巧
39SilverLight下载任意文件技巧        'context.Response.ContentType = "text/plain"
40SilverLight下载任意文件技巧        'context.Response.Write("Hello World!")
41SilverLight下载任意文件技巧
42SilverLight下载任意文件技巧    End Sub

43SilverLight下载任意文件技巧
44SilverLight下载任意文件技巧SilverLight下载任意文件技巧    ReadOnly Property IsReusable()Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
45SilverLight下载任意文件技巧        Get
46SilverLight下载任意文件技巧            Return False
47SilverLight下载任意文件技巧        End Get
48SilverLight下载任意文件技巧    End Property

49SilverLight下载任意文件技巧
50SilverLight下载任意文件技巧End Class

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What to do if the 0x80004005 error code appears. The editor will teach you how to solve the 0x80004005 error code. What to do if the 0x80004005 error code appears. The editor will teach you how to solve the 0x80004005 error code. Mar 21, 2024 pm 09:17 PM

When deleting or decompressing a folder on your computer, sometimes a prompt dialog box "Error 0x80004005: Unspecified Error" will pop up. How should you solve this situation? There are actually many reasons why the error code 0x80004005 is prompted, but most of them are caused by viruses. We can re-register the dll to solve the problem. Below, the editor will explain to you the experience of handling the 0x80004005 error code. Some users are prompted with error code 0X80004005 when using their computers. The 0x80004005 error is mainly caused by the computer not correctly registering certain dynamic link library files, or by a firewall that does not allow HTTPS connections between the computer and the Internet. So how about

Introduction to how to download and install the superpeople game Introduction to how to download and install the superpeople game Mar 30, 2024 pm 04:01 PM

The superpeople game can be downloaded through the steam client. The size of this game is about 28G. It usually takes one and a half hours to download and install. Here is a specific download and installation tutorial for you! New method to apply for global closed testing 1) Search for "SUPERPEOPLE" in the Steam store (steam client download) 2) Click "Request access to SUPERPEOPLE closed testing" at the bottom of the "SUPERPEOPLE" store page 3) After clicking the request access button, The "SUPERPEOPLECBT" game can be confirmed in the Steam library 4) Click the install button in "SUPERPEOPLECBT" and download

Where to download files from Quark Network Disk_How to download Quark Network Disk to local area and share Where to download files from Quark Network Disk_How to download Quark Network Disk to local area and share Mar 21, 2024 pm 03:57 PM

As a convenient and practical network disk tool, Quark can help users easily obtain their favorite resources. What if you want to download a file locally? Let the editor tell you now, let’s learn it together! How to download Quark Network Disk to local sharing method 1. First open the Quark software, enter the homepage, and click the [Cloud Icon] on the lower right; 2. Then on the Quark Network Disk page, we click the [Document] function; 3. Then go to the document page, select the file you want to download, and click the [three-dot icon]; 4. After the final click, we click [Download] in the pop-up dialog box;

How to download and save Douyin videos How to download and save Douyin videos Mar 25, 2024 pm 09:46 PM

How to download and save Douyin videos? You can download and save videos in Douyin short video APP. Most users don’t know how to download and save Douyin videos. Next is the diagram of how to download and save Douyin videos brought by the editor. Text tutorial, interested users come and take a look! Tutorial on how to use Douyin: How to download and save Douyin videos 1. First open the Douyin short video APP, enter the main page and click the [Share] button on the right; 2. After that, the multi-function bar will expand below, slide to the right to find [ Save local] icon; 3. Then you need to wait for the download, and then the [Saved, please go to the album to view] border will appear; 4. Finally jump to the album page, and you can see that the video you just downloaded has been saved.

Detailed steps for downloading files from qq Detailed steps for downloading files from qq Mar 22, 2024 pm 09:10 PM

1. First we open file management. 2. Click Internal Storage. 3. Scroll down and sort to find Tencent (Tencent folder) starting with t. 4. Click to enter and find QQfile_recv, click to enter to view.

Can't UC videos be downloaded? How to download videos in UC browser Can't UC videos be downloaded? How to download videos in UC browser Mar 20, 2024 pm 08:51 PM

UC Browser is a browser that everyone is using. It allows everyone to get some unique online experience. It is super convenient and can search for a variety of resources for you, some of which you cannot enjoy on other platforms. Everyone can view his video works here. The content is very exciting. Everyone is immersed in it and can't stop at all. They also want to download the video locally so that they can watch it at any time. Whenever you want to watch it, you can just When I watched it, it was very convenient. I have sorted out the specific method of downloading the video. I hope it can help you. How to download videos to the local area in UC Browser: 1. Open UC Browser, click on the menu bar, and select Download/Video; 2. Click on the cached video; 3. Click on the video selection

Win11 Tips Sharing: Skip Microsoft Account Login with One Trick Win11 Tips Sharing: Skip Microsoft Account Login with One Trick Mar 27, 2024 pm 02:57 PM

Win11 Tips Sharing: One trick to skip Microsoft account login Windows 11 is the latest operating system launched by Microsoft, with a new design style and many practical functions. However, for some users, having to log in to their Microsoft account every time they boot up the system can be a bit annoying. If you are one of them, you might as well try the following tips, which will allow you to skip logging in with a Microsoft account and enter the desktop interface directly. First, we need to create a local account in the system to log in instead of a Microsoft account. The advantage of doing this is

How to download Beilehu children's songs How to download Beilehu children's songs Mar 28, 2024 am 11:10 AM

As an indispensable accompaniment to children's growth, Beilehu's children's songs have won the love of countless parents and children with their cheerful melody, vivid pictures and entertaining and educational content. In order to allow babies to enjoy the joy brought by children's songs anytime and anywhere, many parents hope to download Beilehu's children's songs to their mobile phones or tablets so that they can listen to their children at any time, but how to save Beilehu's children's songs? On your mobile phone, this tutorial will bring you a detailed introduction. Users who don’t understand it yet can come and read along with this article to learn more. Beilehu Nursery Rhymes Download Children's Songs Multi-Picture Tutorial: Open the software and select a children's song you want to download. The editor takes "Classic Children's Songs" as an example. 2. Click the "Download" button below the children's song star.

See all articles