Take the following steps to start a project and to add some code that burns an ISO file, or a directory of files to disc
[Visual Basic]
Imports Leadtools Imports Leadtools.MediaWriter
[C#]
using Leadtools; using Leadtools.MediaWriter;
[Visual Basic]
Dim mediaWriter as MediaWriter Dim burnerDrive as MediaWriterDrive
[C#]
MediaWriter mediaWriter; MediaWriterDrive burnerDrive;
[Visual Basic]
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) mediaWriter = New MediaWriter() _cmbDrives.Items.Clear() For Each drive As MediaWriterDrive In mediaWriter.Drives _cmbDrives.Items.Add(drive.Name) Next drive _cmbDrives.SelectedIndex = mediaWriter.CurrentDriveNumber + 1 End Sub
[C#]
private void Form1_Load(object sender, System.EventArgs e) { mediaWriter = new MediaWriter(); _cmbDrives.Items.Clear(); foreach (MediaWriterDrive drive in mediaWriter.Drives) { _cmbDrives.Items.Add(drive.Name); } _cmbDrives.SelectedIndex = mediaWriter.CurrentDriveNumber + 1; }
[Visual Basic]
Private Sub _cmbDrives_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) mediaWriter.CurrentDriveNumber = _cmbDrives.SelectedIndex - 1 If Not burnerDrive Is Nothing Then burnerDrive.OnDeviceEvent -= burnerDrive_OnDeviceEvent End If burnerDrive = mediaWriter.CurrentDrive 'Only add device event for valid drives If burnerDrive.DriveNumber <> -1 Then AddHandler burnerDrive.OnDeviceEvent, AddressOf Of MediaWriterDevNotifyEventArgs End If _btnWrite.Enabled = burnerDrive.Writeable End Sub
[C#]
private void _cmbDrives_SelectedIndexChanged(object sender, System.EventArgs e) { mediaWriter.CurrentDriveNumber = _cmbDrives.SelectedIndex - 1; if (burnerDrive != null) burnerDrive.OnDeviceEvent -= burnerDrive_OnDeviceEvent; burnerDrive = mediaWriter.CurrentDrive; //Only add device event for valid drives if (burnerDrive.DriveNumber != -1) burnerDrive.OnDeviceEvent += new EventHandler<MediaWriterDevNotifyEventArgs>(burnerDrive_OnDeviceEvent); _btnWrite.Enabled = burnerDrive.Writeable; }
[Visual Basic]
Private void Function btnWrite_Click(ByVal sender As Object, ByVal e As System.EventArgs) As _ If String.IsNullOrEmpty(_txtInput.Text) Then MessageBox.Show("You must choose an input file" & Constants.vbFormFeed & "older") Return End If Dim burnDisc As MediaWriterDisc = burnerDrive.CreateDisc() burnDisc.SourcePathName = _txtInput.Text burnDisc.VolumeName = "LEAD Media" burnerDrive.BurnDisc(burnDisc) Me.Text = "Writing" Do While burnerDrive.State = MediaWriterState.StateWriting 'Loop until complete Application.DoEvents() Loop this.Text = "Complete"; MessageBox.Show("Complete") End Function
[C#]
private void _ btnWrite_Click(object sender, System.EventArgs e) { if (String.IsNullOrEmpty(_txtInput.Text)) { MessageBox.Show("You must choose an input file\folder"); return; } MediaWriterDisc burnDisc = burnerDrive.CreateDisc(); burnDisc.SourcePathName = _txtInput.Text; burnDisc.VolumeName = "LEAD Media"; burnerDrive.BurnDisc(burnDisc); this.Text = "Writing"; while (burnerDrive.State == MediaWriterState.StateWriting) { //Loop until complete Application.DoEvents(); } this.Text = "Complete"; MessageBox.Show("Complete"); }
[Visual Basic]
Private Sub burnerDrive_OnDeviceEvent(ByVal sender As Object, ByVal e As MediaWriterDevNotifyEventArgs) _btnWrite.Enabled = burnerDrive.Writeable End Sub
[C#]
void burnerDrive_OnDeviceEvent(object sender, MediaWriterDevNotifyEventArgs e) { _btnWrite.Enabled = burnerDrive.Writeable; }
Build, and Run the program to test it.
Select your burner from the drives list, fill the textbox with the path to a valid ISO image or directory of files, and click the "Write" button.