Reputation: 51
I am working on an project that creates ISO files. Basically, all the files needed for the ISO is stored in a temporary directory and just needs to be saved to an ISO file.
I have tried the following code :
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
but that just creates an empty folder like this "C: > Users > Adriaan > AppData > Local and so on. Does anyone have a good example on how to do this since I cannot make out anything from the help file.
Thanks
Upvotes: 0
Views: 1482
Reputation: 51
For anyone else that might come onto this with the same problem, this is how I solved the problem.
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
Upvotes: 2