This project is read-only.

Because a file or directory with the same name already exists.

Jan 19, 2012 at 9:21 PM

My code is this:

Dim args(2) As String
Private Sub Buttonbackupjar_Click(sender As System.Object, e As System.EventArgs) Handles Buttonbackjar.Click
            Using zip As ZipFile = New ZipFile("jar")
                ' Add the file to the Zip archive's root folder.
                zip.AddFile(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) & "\AppData\Roaming\.minecraft\bin\minecraft.jar")
                ' Save the Zip file.
                zip.Save(Application.StartupPath & "\backup\")
            End Using
        Catch ex As Exception
            MessageBox.Show("Error adding file to archive. " + ex.Message)
        End Try
End Sub

Private Sub Buttonjarre_Click(sender As System.Object, e As System.EventArgs) Handles Buttonjarre.Click
        args(0) = Application.StartupPath & "\backup\"
        args(1) = (Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) & "\AppData\Roaming\.minecraft\bin\minecraft.jar")
        Dim worker As System.Threading.Thread
        worker = New System.Threading.Thread(New System.Threading.ParameterizedThreadStart(AddressOf Unzipjar))
        Labeljarentries.Visible = True
        Labeljarentries.Enabled = True
        Catch ex2 As Exception
            Labeljarentries.Text = ("Exception: " & ex2.ToString)
        End Try
End Sub

Private Sub Unzipjar(ByVal args As String())
        Using zip As ZipFile = ZipFile.Read(args(0))
            Dim entry As ZipEntry
            For Each entry In zip
                entry.Extract(args(1), ExtractExistingFileAction.OverwriteSilently)
            Updatejar(String.Format("{0} files restored!", zip.Entries.Count))
        End Using
End Sub

Private Sub Updatejar(ByVal filename As String)
        If Me.InvokeRequired Then
            '' invoke on the proper thread 
            Me.Invoke(New Action(Of String)(AddressOf Updatejar), New Object() {filename})
            Labeljarentries.Text = filename
        End If
End Sub

My error is this:

"Cannot create "C:\Users\Soren\AppData\Roaming\.minecraft\bin\minecraft.jar" because a file or directory with the same name already exists."

My file have many subfolder! "\backup\\Users\Soren\AppData\Roaming\.minecraft\bin\"


What have i done wrong? Please help me.

Btw folder extraction works fine! (Great library!)