所以我想创建这个程序对于一个游戏,将从一个文件夹中以.zip形式提取mod并将它们全部提取到游戏文件夹中,这是代码I到目前为止。我认为button2的代码不能从另一个按钮的文件夹中获得我已经尝试了几件事,但无法让它工作。试图在VB.net中创建一个提取程序
Imports System.IO.Compression
Imports System.IO
Public Class Form1
Dim GameFolder As String
Dim ZipFolder As String
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Close()
End Sub
Public Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim mypath As String
Dim fname As String
mypath = ZipFolder ' Select zip location folder
fname = Dir(mypath & "*.zip") ' get first zip file
Do While Len(fname) > 0
ZipFile.ExtractToDirectory(fname, mypath)
fname = Dir() ' get next matching file
Loop
End Sub
Public Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim fd As FolderBrowserDialog = New FolderBrowserDialog() ' Let the user select the Zip Folder
Dim ZipFolder As String
If fd.ShowDialog() = DialogResult.OK Then
ZipFolder = fd.SelectedPath 'Set the Zipfolder string to the output of the FolderBrowser
End If
End Sub
Public Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim fd As FolderBrowserDialog = New FolderBrowserDialog() 'Let the user select the game folder
Dim GameFolder As String
If fd.ShowDialog() = DialogResult.OK Then
GameFolder = fd.SelectedPath 'Set the GameFolder string to the output of the FolderBrowser
End If
End Sub
End Class
如果在Button3_Click中删除Dim ZipFolder As String,会发生什么情况? – SearchAndResQ
他甚至应该在Button4_Click中删除'Dim GameFolder As String'。 – muffi
删除'Dim ZipFolder As String'和'Dim GameFolder As String'后它仍然不起作用,没有像以前那样发生。 –