Leadtools.MediaWriter Namespace : MediaWriterException Class |
public class MediaWriterException : System.Exception, System.IDisposable, System.Runtime.InteropServices._Exception, System.Runtime.Serialization.ISerializable
'Declaration Public Class MediaWriterException Inherits System.Exception Implements System.IDisposable, System.Runtime.InteropServices._Exception, System.Runtime.Serialization.ISerializable
'Usage Dim instance As MediaWriterException
public sealed class MediaWriterException : IClosable //In WinRT the IDisposable interface is replaced by IClosable, System.Runtime.InteropServices._Exception, ~Remove~
function Leadtools.MediaWriter.MediaWriterException()
public ref class MediaWriterException : public System.Exception, System.IDisposable, System.Runtime.InteropServices._Exception, System.Runtime.Serialization.ISerializable
The MediaWriterException class defines a Code property that you can examine to determine what caused the error.
<Test> _ Public Sub NoDiscErrorExample() Try Dim writer As MediaWriter = New MediaWriter() Dim drives As List(Of MediaWriterDrive) = writer.Drives Dim drive As MediaWriterDrive = drives(1) Dim disc As MediaWriterDisc = drive.CreateDisc() disc.VolumeName = "TEST DISC" disc.SourcePathName = Path.Combine(LEAD_VARS.ImagesDir, "InputFiles") drive.EjectDisc() System.Threading.Thread.Sleep(5000) ' wait for 5 seconds ' Make sure there is no disc in the drive drive.LoadDisc() drive.BurnDisc(disc) ' wait loop for demonstration purposes Do While drive.State <> MediaWriterState.StateIdle System.Windows.Forms.Application.DoEvents() System.Threading.Thread.Sleep(100) Loop Catch ex As MediaWriterException If MediaWriterExceptionCode.NoDisc = ex.Code Then MessageBox.Show("No disc in drive!") End If End Try End Sub Public NotInheritable Class LEAD_VARS Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" End Class
public void NoDiscErrorExample() { try { MediaWriter writer = new MediaWriter(); List<MediaWriterDrive> drives = writer.Drives; MediaWriterDrive drive = drives[1]; MediaWriterDisc disc = drive.CreateDisc(); disc.VolumeName = "TEST DISC"; disc.SourcePathName = Path.Combine(LEAD_VARS.ImagesDir, "InputFiles"); drive.EjectDisc(); System.Threading.Thread.Sleep(5000); // wait for 5 seconds // Make sure there is no disc in the drive drive.LoadDisc(); drive.BurnDisc(disc); // wait loop for demonstration purposes while (drive.State != MediaWriterState.StateIdle) { System.Windows.Forms.Application.DoEvents(); System.Threading.Thread.Sleep(100); } } catch (MediaWriterException ex) { if (MediaWriterExceptionCode.NoDisc == ex.Code) MessageBox.Show("No disc in drive!"); } } static class LEAD_VARS { public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2