如何将binaryWrite文件分解为多个块 [英] How to break up binaryWrite file into multiple chunks

查看:97
本文介绍了如何将binaryWrite文件分解为多个块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在做一个binaryWrite,允许用户下载文件。如果文件太大,则会出现问题

。我的一些文件接近

100 megs。我在msdn上看到,如果数据大于4MB,那么建议将它分成多个块来建立

http:// msdn .microsoft.com / library / de ... 4b95130b4a.asp


如何做到这一点?

感谢您的时间和帮助:)


ps以下是我用于流媒体的子


Private Sub streamDocs(path,filename,originalFileName,contentType)

Response.AddHeader

" content-disposition"," attachment; filename ="& originalFileNa me

Response.ContentType = contentType

Dim BinaryStream,Fil,fs

设置BinaryStream = CreateObject(" ADODB.Stream")

set fs = Server.CreateObject(" Scripting .FileSystemObject")

设置Fil = fs.GetFile(路径&" \" & filename)''打开文件

BinaryStream.Type = 1

BinaryStream.Open

BinaryStream.LoadFromFile Fil.path

Response.BinaryWrite BinaryStream.Read

BinaryStream.Cancel

BinaryStream.Close

set BinaryStream = nothing

结束分

Hi,

I am doing a binaryWrite to allow users to download files. The problem
occurs if the file is too big. Some of the files i have are close to
100 megs. I read on msdn that if the data is greater than 4MB it is
advisable to break it up into multiple chunks

http://msdn.microsoft.com/library/de...4b95130b4a.asp

How would that be done?
Thanks for your time and help :)

ps below is the sub i use for streaming

Private Sub streamDocs(path, filename, originalFileName, contentType)
Response.AddHeader
"content-disposition","attachment;filename="&originalFileNa me
Response.ContentType = contentType
Dim BinaryStream, Fil, fs
Set BinaryStream = CreateObject("ADODB.Stream")
set fs = Server.CreateObject("Scripting.FileSystemObject")
Set Fil = fs.GetFile(path & "\" &filename) ''Open file
BinaryStream.Type = 1
BinaryStream.Open
BinaryStream.LoadFromFile Fil.path
Response.BinaryWrite BinaryStream.Read
BinaryStream.Cancel
BinaryStream.Close
set BinaryStream = nothing
End sub

推荐答案

2006年9月13日星期三09:03:42 -0500,Katie< Dn *** ******@gmail.com写道:
On Wed, 13 Sep 2006 09:03:42 -0500, Katie <Dn*********@gmail.comwrote:




我正在做一个binaryWrite来允许用户下载文件。如果文件太大,则会出现问题

。我的一些文件接近

100 megs。我在msdn上读到,如果数据大于4MB,那么建议将b-b分成多个块
Hi,

I am doing a binaryWrite to allow users to download files. The problem
occurs if the file is too big. Some of the files i have are close to
100 megs. I read on msdn that if the data is greater than 4MB it is
advisable to break it up into multiple chunks



可选的第一个参数到Read()方法将允许你指定读取的最大字节数
。所以你有这个:

The optional first argument to the Read() method will allows you to
specify the maximum number of bytes read. So where you have this:


Response.BinaryWrite BinaryStream.Read
Response.BinaryWrite BinaryStream.Read



你可以把它改成这个以千字节块的形式写入数据:


Dim i

For i = 0 To BinaryStream.Size

Response.BinaryWrite BinaryStream.Read(1000)

下一页


您可以找到所有Stream对象属性的文档和

微软网站上的方法。


流对象属性,方法和事件
http://windowssdk.msdn.microsoft.com ... / ms677486.aspx


-

Justin Piper

Bizco Technologies
http://www.bizco.com/


2006年9月13日星期三09:22:36 -0500, Justin Piper< jp **** @ bi zco.comwrote:
On Wed, 13 Sep 2006 09:22:36 -0500, Justin Piper <jp****@bizco.comwrote:

For i = 0 To BinaryStream.Size
For i = 0 To BinaryStream.Size



哎呀,当然应该阅读,For i = 0 To BinaryStream.Size Step

1000。


-

Justin Piper

Bizco Technologies
http://www.bizco.com/


Justin Piper在2006年9月13日写的

microsoft.public.inetserver.asp.general:
Justin Piper wrote on 13 sep 2006 in
microsoft.public.inetserver.asp.general:

2006年9月13日星期三09:22:36 -0500,Justin Piper< jp **** @ bizco.com>

写道:
On Wed, 13 Sep 2006 09:22:36 -0500, Justin Piper <jp****@bizco.com>
wrote:

>对于i = 0到BinaryStream.Size
> For i = 0 To BinaryStream.Size



哎呀,当然应该读,For i = 0 To BinaryStream.Size

步骤1000。


Whoops, that should of course read, "For i = 0 To BinaryStream.Size
Step 1000".



或:


For i = 0 To BinaryStream.Size / 1000


-

Evertjan。

荷兰。

(请将x''es更改为我的电子邮件地址中的点数)

or:

For i = 0 To BinaryStream.Size/1000

--
Evertjan.
The Netherlands.
(Please change the x''es to dots in my emailaddress)


这篇关于如何将binaryWrite文件分解为多个块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆