How to erase a DVD+RW
If you want to erase the contents of a DVD+RW media you should write 0s in the sectors that contain the data you want to erase. Here is the C# code:
// TODO: Initialize the device variable using PrimoSoftware.Burner.DeviceEnumerator object
PrimoSoftware.Burner.Device device;
// Set this variable with the desired number of blocks to fill with 0s.
// 2000 blocks are enough to erase the ISO and UDF file system descriptors
// from the target medium.
long blocksToWrite = 2000;
device.StartDVDSession(false, WriteMethod.DvdIncremental, false);
// Start writing 0s from the first block on the target medium
device.NewSessionStartAddress = 0;
device.StartDVDTrack((int)blocksToWrite));
const int writeChunk = 32;
// Create a data buffer filled with 0s that will be written repeatedly on the target medium
byte[] dummyBuffer = new byte[writeChunk * (int)BlockSize.Dvd];
long lAddrBuf1 = 0;
long lAddrBuf2 = 0;
int buf1Size = 0;
int buf2Size = 0;
int blocks = blocksToWrite;
int blocksChunk = 0;
// Perform the actual writing
while ((blocksChunk = Math.Min(blocks, writeChunk)) > 0)
{
buf1Size = 0;
buf2Size = 0;
device.LockOutputBuffer(blocksChunk,
out lAddrBuf1, out buf1Size,
out lAddrBuf2, out buf2Size);
// TODO: Copy the content from dummyBuffer into the memory pointed to by lAddrBuf1 and lAddrBuf2
device.UnlockOutputBuffer(blocksChunk);
blocks -= blocksChunk;
}
device.EndDVDTrack(true);
device.EndDVDSession(true);