如何清空TStream?以便再次.savetostream?

collecte 2003-07-04 05:00:36
如TMemoryStream

好像没有 .clear属性。
...全文
150 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
tohell 2003-07-04
  • 打赏
  • 举报
回复
astream:TMemoryStream;就有了啊
collecte 2003-07-04
  • 打赏
  • 举报
回复
astream:TStream;


astream:=TMemoryStream.create;之后

astream.clear不能通过编译
firetoucher 2003-07-04
  • 打赏
  • 举报
回复
倒,有啊,不过不是属性,而是clear方法!
<% Dim oUpFileStream 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 oUpFileStream.Close Set oUpFileStream = Nothing End If End Sub Public Sub GetDate (RetSize) '定义变量 Dim RequestBinDate,sSpace,bCrLf,sInfo,iInfoStart,iInfoEnd,tStream,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 tStream = Server.CreateObject ("ADODB.Stream") Set oUpFileStream = Server.CreateObject ("ADODB.Stream") oUpFileStream.Type = 1 oUpFileStream.Mode = 3 oUpFileStream.Open oUpFileStream.Write Request.BinaryRead (Request.TotalBytes) oUpFileStream.Position = 0 RequestBinDate = oUpFileStream.Read iFormEnd = oUpFileStream.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 tStream.Type = 1 tStream.Mode = 3 tStream.Open oUpFileStream.Position = iFormStart oUpFileStream.CopyTo tStream,iInfoEnd-iFormStart tStream.Position = 0 tStream.Type = 2 tStream.CharSet = "gb2312" sInfo = tStream.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 '如果是表单项目 tStream.Close tStream.Type = 1 tStream.Mode = 3 tStream.Open oUpFileStream.Position = iInfoEnd oUpFileStream.CopyTo tStream,iFormStart-iInfoEnd-2 tStream.Position = 0 tStream.Type = 2 tStream.CharSet = "gb2312" sFormValue = tStream.ReadText If Form.Exists (sFormName) Then Form (sFormName) = Form (sFormName) & ", " & sFormValue else form.Add sFormName,sFormValue End If End If tStream.Close iFormStart = iFormStart+iStart+2 '如果到文件尾了就退出 Loop Until (iFormStart+2) = iFormEnd RequestBinDate = "" Set tStream = 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 oFileStream Set oFileStream = CreateObject ("ADODB.Stream") oFileStream.Type = 1 oFileStream.Mode = 3 oFileStream.Open oUpFileStream.Position = FileStart oUpFileStream.CopyTo oFileStream,FileSize oFileStream.SaveToFile Path,2 oFileStream.Close Set oFileStream = Nothing End Function
DIZipWriter is a Delphi component to create PKZip-compatible ZIP archives. Archive output is based on TStream and writes directlyfiles (TFileStream), memory (TMemoryStream), or database BLOBs(TBlobStream). 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 Streams 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 Streaming Direct streaming allows objects to stream their data directly to a ZIP archive using their ownSaveToStream() 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.SaveToStream(DIZipWriter.CurrentEntryStream); // Save a database BLOB to a ZIP archive. MyBlob.SaveToStream(DIZipWriter.CurrentEntryStream); Direct streaming 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 streaming 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

5,390

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧