Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Available space on blank dvd / blu-ray discs (IMAPI)

Tags:

c#

.net

imapi

Since my original question was a bit too vague, let me clarify.

My goals are:

  1. to estimate blank disc size after selecting filesystem via IMAPI
  2. to estimate space which my file will consume on this disc if i burn it.

What i would like to know:

  1. Is it possible to get bytes per sector for selected file system programmatically
  2. If not, is there default value for bytes per sector which IMAPI uses for different file systems / media types, and is it documented somewhere.
like image 241
Nikita B Avatar asked Sep 14 '12 11:09

Nikita B


1 Answers

Ok, so the short answer to my question is: one can safely assume, that sector size for DVD/BD discs = 2048 bytes.

The reason, why i was getting different sizes during my debug sessions, was because of an error in code, which retrieved sectors count :)

Mentioned code block was copypasted from http://www.codeproject.com/Articles/24544/Burning-and-Erasing-CD-DVD-Blu-ray-Media-with-C-an , so just in case im posting a quick fix.

original code:

discFormatData = new MsftDiscFormat2Data();
discFormatData.Recorder = discRecorder;
IMAPI_MEDIA_PHYSICAL_TYPE mediaType = discFormatData.CurrentPhysicalMediaType;
fileSystemImage = new MsftFileSystemImage();
fileSystemImage.ChooseImageDefaultsForMediaType(mediaType);
if (!discFormatData.MediaHeuristicallyBlank)
{
     fileSystemImage.MultisessionInterfaces = discFormatData.MultisessionInterfaces;
     fileSystemImage.ImportFileSystem();
}
Int64 freeMediaBlocks = fileSystemImage.FreeMediaBlocks;

fixed code:

discFormatData = new MsftDiscFormat2Data { Recorder = discRecorder };
fileSystemImage = new MsftFileSystemImage();
fileSystemImage.ChooseImageDefaults(discRecorder);
if (!discFormatData.MediaHeuristicallyBlank)
{
    fileSystemImage.MultisessionInterfaces = discFormatData.MultisessionInterfaces;
    fileSystemImage.ImportFileSystem();
}
Int64 freeMediaBlocks = fileSystemImage.FreeMediaBlocks;
like image 66
Nikita B Avatar answered Sep 19 '22 14:09

Nikita B