NWHomeDir_CSExtension.vb: Function ArchiveHomeDir

Imports zbitz

Private Function ArchiveHomeDir(ByVal path As String) As Int16
    Dim status As Int16
    Dim archive As New Czzip
    Dim archivePath As String = “\\” & path.Split(“\”)(2) & “\” & path.Split(“\”)(3) & “\” & “ARCHIVE\” & path.Split(“\”)(5) & “.zip”

    If System.IO.File.Exists(archivePath) Then
        Throw New UnexpectedDataException(“Archive file ” & archivePath & ” already exists”)
    End If

    Dim logtxt = Date.Now & ” Zipping ” & path & “: “
    status = archive.ZipFile(path, archivePath)
    If status = 0 Then ‘Confirm zip file exists
         logFile.WriteLine(logtxt & “Success”)
         If Not System.IO.File.Exists(archivePath) Then
        status = -1
        End If
   Else
        logFile.WriteLine(logtxt & “Failed with error ” & status & “, ” & archive.LastMsg)
    End If

    Return status

End Function