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

问题描述

限时删除!!




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

。我的一些文件接近

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




如何做到这一点?

感谢您的时间和帮助:)


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

推荐答案



可选的第一个参数到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:



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


Dim i

For i = 0 To BinaryStream.Size

Response.BinaryWrite BinaryStream.Read(1000)

下一页


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

微软网站上的方法。


流对象属性,方法和事件



-

Justin Piper

Bizco Technologies




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

1000。


-

Justin Piper

Bizco Technologies




哎呀,当然应该读,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文件分解为多个块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 23:43