I have a file "C:\Users\Wangui Kamande\Desktop\social.txt" which I would like to compress into a .zip file the location "C:\Users\Wangui Kamande\Desktop".
I got the following code from the Microsoft site but I am not so sure about how to go about this.
Is it that the file "C:\Users\Wangui Kamande\Desktop\social.txt" has to be in a folder?
The code from the mircosoft site is:
Private Sub btnCompress_Click(sender As Object, e As EventArgs) Handles btnCompress.Click
Dim startPath As String = "c:\example\start"
Dim zipPath As String = "c:\example\result.zip"
Dim extractPath As String = "c:\example\extract"
You want the
ZipArchive.CreateEntryFromFile extension method to add individual files to a zip...
Using zip = ZipFile.Open("C:\Users\Wangui Kamande\Desktop\social.zip", ZipArchiveMode.Create) zip.CreateEntryFromFile("C:\Users\Wangui Kamande\Desktop\social.txt", "social.txt") End Using