简体   繁体   中英

File Overwrite when Unzipping file from VB.Net

Need a little help with working with ZIP files, I've made a autopupdate application for my main app it works fine and downloads the Zip from the server and I am able to extract it completely, but problem is if the files are already there and if i try to unzip it again it shows option of Replacing i want to avoid that option and just replace it without giving alert. Please do let me know how can i can i do it.

The code for Unzipping is as follow :

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim shObj As Object = Activator.CreateInstance(Type.GetTypeFromProgID("Shell.Application"))
    Dim output As Object = shObj.namespace((Application.StartupPath))
    Dim input As Object = shObj.NameSpace((Application.StartupPath + "\temp.zip"))
    output.CopyHere((input.items), 4)
End Sub

Why not using ZipFile class?

https://msdn.microsoft.com/en-us/library/system.io.compression.zipfile(v=vs.110).aspx

It has been a while since I used it but as far as I remember it replaces the old files with the extracted ones.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM