من از کد و کلاس زیر برای فشرده سازی و رمز دار کردن فایل backup استفاده کردم امیدوارم مفید واقع شود.
'-----------------compress file and code -----------
Dim filename AsString
filename = sfd.FileName + ".bak"
Try
_ZipUtility.CompressFile(filename, sfd.FileName)
Catch ex As Exception
MessageBox.Show("There was an error compressing the file" & vbCrLf & ex.Message, "Compression Sample", MessageBoxButtons.OK, MessageBoxIcon.Error)
EndTry
که در آن sfd نام فایل بک آپ است که از savefiledialog خوانده می شود.
البته در ادامه با این کد فایل اصلی را نیز حذف می کنیم.
File.Delete(filename)
این هم برای خارج گردن از حالت فشرده
Dim filename AsString
filename = ofd.FileName + ".bak"
Try
_ZipUtility.DecompressFile(ofd.FileName, filename)
Catch ex As Exception
MessageBox.Show("There was an error compressing the file" & vbCrLf & ex.Message, "Compression Sample", MessageBoxButtons.OK, MessageBoxIcon.Error)
EndTry
که اینبار ofd نام فایل است که از openfiledialog خوانده می شود.
فایل کلاس را هم ضمیمه کردم