asp.net - Compressing a directory on the go using Xceed -


i have directory contains several files. want compress folder zip (using xceed third party dll library) , push user through http. @ same time create log of files inside folder , append part of compressed file.

i using dotnetzip , working perfectly. need equivalant of in xceed.

below code using dotnetzip

imports ionic.zip     ' tell browser we're sending zip file!     dim downloadfilename string = string.format("yourdownload-{0}.zip", datetime.now.tostring("yyyy-mm-dd-hh_mm_ss"))     response.contenttype = "application/zip"     response.addheader("content-disposition", "filename=" & downloadfilename) ' zip contents of selected files using zip new zipfile()      ' construct contents of readme.txt file included in zip     dim readmemessage string = string.format("your zip file {0} contains following files:{1}{1}", downloadfilename, environment.newline)      integer = 0 maindirs.length - 1         readmemessage &= string.concat(vbtab, "* ", maindirs(i), environment.newline)         ' add file zip (use value of "" second parameter put files in "root" folder)         zip.addfile(maindirs(i), "your files")     next      ' add readme.txt file zip     zip.addentry("readme.txt", readmemessage, encoding.ascii)      ' send contents of zip output stream     zip.save(response.outputstream) end using end sub 

after , forth emails xceed support. kind me find right solution problem.

here code works fine.

' tell browser we're sending zip file!         dim downloadfilename string = string.format("yourdownload-{0}.zip", datetime.now.tostring("yyyy-mm-dd-hh_mm_ss"))         response.contenttype = "application/zip"         response.addheader("content-disposition", "filename=" & downloadfilename)      dim itemheader new zipitemlocalheader()      ' zip contents of selected files     using zip new zipwriter(response.outputstream)          dim directoryinfo new directoryinfo(folderpath)         if directoryinfo.exists              ' construct contents of readme.txt file included in zip             dim readmemessage string = string.format("your zip file {0} contains following " & maindirs.length & " files:{1}{1}", downloadfilename, environment.newline)              'get files in current directory , subdirectories.             dim _files fileinfo() = directoryinfo.getfiles("*.*", searchoption.alldirectories)              dim buffer byte() = new byte(65536) {}              dim count integer = 0             each file fileinfo in _files                 'create zipitemlocalheader current item , write archive.                 dim zipitemlocalheader1 new zipitemlocalheader(file.name)                 zip.writeitemlocalheader(zipitemlocalheader1)                  readmemessage &= string.concat(vbtab, (count + 1).tostring & "- ", path.getfilename(file.fullname), environment.newline)                  using fs filestream = file.openread()                     'write current item's data zip archive                     zip.writeitemdata(fs, buffer, 0, buffer.length)                 end using                  count += 1             next file              itemheader.filename = "readme.txt"             zip.writeitemlocalheader(itemheader)              ' add readme.txt file zip             dim data() byte = system.text.encoding.ascii.getbytes(readmemessage)             zip.writeitemdata(data)              'close zip archive. writes archive's central header.             zip.closezipfile()         end if      end using 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -