2015-06-16 81 views
0

我正在創建一個創建ISO文件的項目。基本上,ISO所需的所有文件都存儲在臨時目錄中,只需將其保存到ISO文件即可。使用.net創建ISO文件DiscUtils

我曾嘗試下面的代碼:

 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一個空文件夾:>用戶>阿德里安> AppData的>本地等有沒有人對如何很好的例子。要做到這一點,因爲我不能做出來,從幫助文件什麼。

感謝

回答

0

對於其他人,可能出現到這個同樣的問題,這是我解決了這個問題。

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