我正在开发一个创建ISO文件的项目。基本上,ISO所需的所有文件都存储在临时目录中,只需要保存到ISO文件中。
我尝试过以下代码:
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim cdBuilder = New CDBuilder()
cdBuilder.UseJoliet = True
cdBuilder.VolumeIdentifier = TextBox1.Text
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
If SaveFileDialog1.FileName = "" Then
Else
For Each dr In My.Computer.FileSystem.GetDirectories(My.Computer.FileSystem.SpecialDirectories.Temp & "\TempISODir")
Next
cdBuilder.Build(SaveFileDialog1.FileName)
End If
End If
End Sub
但是这只会创建一个空文件夹,例如“C:>用户> Adriaan> AppData>本地等等。有没有人有一个很好的例子来说明如何做到这一点,因为我无法从帮助文件。
由于
答案 0 :(得分:1)
对于其他可能遇到同样问题的人来说,这就是我解决问题的方法。
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim iso = New CDBuilder()
iso.UseJoliet = True
iso.VolumeIdentifier = TextBox1.Text
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
If SaveFileDialog1.FileName = "" Then
Else
Dim di As New DirectoryInfo(My.Computer.FileSystem.SpecialDirectories.Temp & "\TempISODir")
PopulateFromFolder(iso, di, di.FullName)
iso.Build(SaveFileDialog1.FileName)
End If
End If
End Sub
Private Shared Sub PopulateFromFolder(builder As CDBuilder, di As DirectoryInfo, basePath As String)
For Each file As FileInfo In di.GetFiles()
builder.AddFile(file.FullName.Substring(basePath.Length), file.FullName)
Next
For Each dir As DirectoryInfo In di.GetDirectories()
PopulateFromFolder(builder, dir, basePath)
Next
End Sub