社区
Delphi
帖子详情
如何清空TStream?以便再次.savetostream?
collecte
2003-07-04 05:00:36
如TMemoryStream
好像没有 .clear属性。
...全文
150
3
打赏
收藏
如何清空TStream?以便再次.savetostream?
如TMemoryStream 好像没有 .clear属性。
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
3 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
tohell
2003-07-04
打赏
举报
回复
astream:TMemoryStream;就有了啊
collecte
2003-07-04
打赏
举报
回复
astream:TStream;
astream:=TMemoryStream.create;之后
astream.clear不能通过编译
firetoucher
2003-07-04
打赏
举报
回复
倒,有啊,不过不是属性,而是clear方法!
BBS论坛的论坛代码
<% Dim oUpFile
Stream
Class UpFile_Class Dim Form,File,Version,Err Private Sub Class_Initialize Version = "无惧上传类 Version V1.0" Err = -1 End Sub Private Sub Class_Terminate '清除变量及对像 If Err < 0 Then Form.RemoveAll Set Form = Nothing File.RemoveAll Set File = Nothing oUpFile
Stream
.Close Set oUpFile
Stream
= Nothing End If End Sub Public Sub GetDate (RetSize) '定义变量 Dim RequestBinDate,sSpace,bCrLf,sInfo,iInfoStart,iInfoEnd,t
Stream
,iStart,oFileInfo Dim iFileSize,sFilePath,sFileType,sFormValue,sFileName Dim iFindStart,iFindEnd Dim iFormStart,iFormEnd,sFormName '代码开始 If Request.TotalBytes < 1 Then Err = 1 Exit Sub End If If RetSize > 0 Then If Request.TotalBytes > RetSize Then Err = 2 Exit Sub End If End If Set Form = Server.CreateObject ("Scripting.Dictionary") Form.CompareMode = 1 Set File = Server.CreateObject ("Scripting.Dictionary") File.CompareMode = 1 Set t
Stream
= Server.CreateObject ("ADODB.
Stream
") Set oUpFile
Stream
= Server.CreateObject ("ADODB.
Stream
") oUpFile
Stream
.Type = 1 oUpFile
Stream
.Mode = 3 oUpFile
Stream
.Open oUpFile
Stream
.Write Request.BinaryRead (Request.TotalBytes) oUpFile
Stream
.Position = 0 RequestBinDate = oUpFile
Stream
.Read iFormEnd = oUpFile
Stream
.Size bCrLf = ChrB (13) & ChrB (10) '取得每个项目之间的分隔符 sSpace = MidB (RequestBinDate,1, InStrB (1,RequestBinDate,bCrLf)-1) iStart = LenB (sSpace) iFormStart = iStart+2 '分解项目 Do iInfoEnd = InStrB (iFormStart,RequestBinDate,bCrLf & bCrLf)+3 t
Stream
.Type = 1 t
Stream
.Mode = 3 t
Stream
.Open oUpFile
Stream
.Position = iFormStart oUpFile
Stream
.CopyTo t
Stream
,iInfoEnd-iFormStart t
Stream
.Position = 0 t
Stream
.Type = 2 t
Stream
.CharSet = "gb2312" sInfo = t
Stream
.ReadText '取得表单项目名称 iFormStart = InStrB (iInfoEnd,RequestBinDate,sSpace)-1 iFindStart = InStr (22,sInfo,"name=""",1)+6 iFindEnd = InStr (iFindStart,sInfo,"""",1) sFormName = Mid (sinfo,iFindStart,iFindEnd-iFindStart) '如果是文件 If InStr (45,sInfo,"filename=""",1) > 0 Then Set oFileInfo = new FileInfo_Class '取得文件属性 iFindStart = InStr (iFindEnd,sInfo,"filename=""",1)+10 iFindEnd = InStr (iFindStart,sInfo,"""",1) sFileName = Mid (sinfo,iFindStart,iFindEnd-iFindStart) oFileInfo.FileName = Mid (sFileName,InStrRev (sFileName, "\")+1) oFileInfo.FilePath = Left (sFileName,InStrRev (sFileName, "\")+1) oFileInfo.FileExt = Mid (sFileName,InStrRev (sFileName, ".")+1) iFindStart = InStr (iFindEnd,sInfo,"Content-Type: ",1)+14 iFindEnd = InStr (iFindStart,sInfo,vbCr) oFileInfo.FileType = Mid (sinfo,iFindStart,iFindEnd-iFindStart) oFileInfo.FileStart = iInfoEnd oFileInfo.FileSize = iFormStart -iInfoEnd -2 oFileInfo.FormName = sFormName file.add sFormName,oFileInfo else '如果是表单项目 t
Stream
.Close t
Stream
.Type = 1 t
Stream
.Mode = 3 t
Stream
.Open oUpFile
Stream
.Position = iInfoEnd oUpFile
Stream
.CopyTo t
Stream
,iFormStart-iInfoEnd-2 t
Stream
.Position = 0 t
Stream
.Type = 2 t
Stream
.CharSet = "gb2312" sFormValue = t
Stream
.ReadText If Form.Exists (sFormName) Then Form (sFormName) = Form (sFormName) & ", " & sFormValue else form.Add sFormName,sFormValue End If End If t
Stream
.Close iFormStart = iFormStart+iStart+2 '如果到文件尾了就退出 Loop Until (iFormStart+2) = iFormEnd RequestBinDate = "" Set t
Stream
= Nothing End Sub End Class '文件属性类 Class FileInfo_Class Dim FormName,FileName,FilePath,FileSize,FileType,FileStart,FileExt '保存文件方法 Public Function SaveToFile (Path) On Error Resume Next Dim oFile
Stream
Set oFile
Stream
= CreateObject ("ADODB.
Stream
") oFile
Stream
.Type = 1 oFile
Stream
.Mode = 3 oFile
Stream
.Open oUpFile
Stream
.Position = FileStart oUpFile
Stream
.CopyTo oFile
Stream
,FileSize oFile
Stream
.SaveToFile Path,2 oFile
Stream
.Close Set oFile
Stream
= Nothing End Function
DIZipWriter v6.2.0 for D7-XE10.1 ZIP 压缩 解压缩
DIZipWriter is a Delphi component to create PKZip-compatible ZIP archives. Archive output is based on T
Stream
and writes directlyfiles (TFile
Stream
), memory (TMemory
Stream
), or database BLOBs(TBlob
Stream
). DIZipWriter's functionality is contained in its main class, TDIZipWriter, with methods to create new ZIP archives and write various types of data like: Files
Stream
s Strings Memory Buffers DIZipWriter allows applications to write to an archive entry as many times as they seem necessary. This allows to create the new archive entry even before the first chunk of data is available. As data flows in (for example from a slow download), they can write it in small chunks at a time. DIZipWriter outputs all data to the archive straight away, with no need for temporary storage: It does not create any temporary files and does not use huge amount of memory for buffering. It is nevertheless possible to create an archive entirely in memory if desired. DIZipWriter stores a global archive comment as well as individual comments for each individual entry. Long file names are supported, just as absolute and relative path names. Direct
Stream
ing Direct
stream
ing allows objects to
stream
their data directly to a ZIP archive using their ownSaveT
o
Stream
() procedure: // Save a TBitMap image to a ZIP archive. // Create and initialize a bitmap image. Img := TBitMap.Create; // Add a new entry to the ZIP archive. DIZipWriter.AddEntry('MyImage'); // Write the bitmap to the archive's entry
stream
. Img.SaveT
o
Stream
(DIZipWriter.CurrentEntry
Stream
); // Save a database BLOB to a ZIP archive. MyBlob.SaveT
o
Stream
(DIZipWriter.CurrentEntry
Stream
); Direct
stream
ing is very efficient because its avoids all temporary storage of bitmap and BLOB data. Other ZIP writing libraries usually require this extra step and forece applications to touch object data at least twice: 1st for
stream
ing it out and 2nd for reading it back. Omitting this extra step helps DIZipWriter to perform faster and uses less resources than the competition. Advanced Encryption
ASP化境无组件上传
改良版T
Stream
类
包含IDEA、Blowfish、RC5、RC6等算法之加密解密改良版T
Stream
类,并提供CRC16及CRC32等Checksum检查核对算法,以及zLib压缩及解压缩的功能(1.0版,附源码)
T
Stream
类说明文档
T
Stream
类说明文档
Delphi
5,390
社区成员
262,735
社区内容
发帖
与我相关
我的任务
Delphi
Delphi 开发及应用
复制链接
扫一扫
分享
社区描述
Delphi 开发及应用
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章