SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

VB.NET Zip without path stored.

Last post 06-04-2008 8:55 PM by JohnReilly. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 05-07-2008 11:17 AM

    • aiya
    • Not Ranked
    • Joined on 05-07-2008
    • Posts 1

    VB.NET Zip without path stored.

    I am using Sharpzip to zip an Excel file with password protected, based on the following codes. How can I remove the path stored in the ZIP file ?

    ========================================================================================= 

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

            Dim strZip As String = Server.MapPath("test_folder/ttzip.zip")
            Dim strText As String = Server.MapPath("cs3.xls")

            Dim ZipOut As New ZipOutputStream(File.Create(strZip))

            ZipOut.SetLevel(1)
            ZipOut.Password = "123456"

            Dim entry As New ZipEntry(strText)
            ZipOut.PutNextEntry(entry)

            Dim fs As FileStream
            fs = New FileStream(strText, FileMode.Open)

            Dim bytes(CType(fs.Length, Integer)) As Byte
            fs.Read(bytes, 0, CInt(fs.Length))
            ZipOut.Write(bytes, 0, CInt(fs.Length))
            fs.Close()

            ZipOut.Finish()
            ZipOut.Close()

        End Sub

    =========================================================================================

    Thank you very much.

     

  • 06-04-2008 8:55 PM In reply to

    Re: VB.NET Zip without path stored.

    Hi,

    Read the FAQ!

    Hint - The following has no path

    Dim entry As New ZipEntry("A")

    while this does

    Dim entry As New ZipEntry("path\file")

Page 1 of 1 (2 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.