D
Dennis
I found some code that was posted on codeguru.com for creating a .zip
file in VB. I want to do the same thing in VB.Net but it doesn't work.
Here is the original code:
Private Sub Command1_Click()
CreateEmptyZip "c:\testzip.zip"
With CreateObject("Shell.Application")
.NameSpace("c:\testzip.zip").CopyHere "c:\test.txt"
End With
End Sub
Public Sub CreateEmptyZip(sPath)
Dim strZIPHeader As String
strZIPHeader = Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18,
0)
With CreateObject("Scripting.FileSystemObject")
.CreateTextFile(sPath).Write strZIPHeader
End With
End Sub
I modified the last sub to work in VB.Net and that part seems to work
.... it does create an empty C:\testzip.zip file that opens fine in
winzip.
But the part that adds C:\test.txt to the archive fails with an error
(cannot create output file). C:\test.txt does exist.
Any idea what I am doing wrong?
TIA,
file in VB. I want to do the same thing in VB.Net but it doesn't work.
Here is the original code:
Private Sub Command1_Click()
CreateEmptyZip "c:\testzip.zip"
With CreateObject("Shell.Application")
.NameSpace("c:\testzip.zip").CopyHere "c:\test.txt"
End With
End Sub
Public Sub CreateEmptyZip(sPath)
Dim strZIPHeader As String
strZIPHeader = Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18,
0)
With CreateObject("Scripting.FileSystemObject")
.CreateTextFile(sPath).Write strZIPHeader
End With
End Sub
I modified the last sub to work in VB.Net and that part seems to work
.... it does create an empty C:\testzip.zip file that opens fine in
winzip.
But the part that adds C:\test.txt to the archive fails with an error
(cannot create output file). C:\test.txt does exist.
Any idea what I am doing wrong?
TIA,