既然我原来的问题有点含糊不清,让我澄清一下。
我的目标是:
我想知道的是:
发布于 2012-09-17 08:12:44
好的,所以我的问题的简短答案是:人们可以安全地假设,DVD/BD光盘的扇区大小= 2048字节。
我在调试会话中获得不同大小的原因,是因为代码中出现了一个错误,其中检索到扇区计数:)
上面提到的代码块是从http://www.codeproject.com/Articles/24544/Burning-and-Erasing-CD-DVD-Blu-ray-Media-with-C-an复制的,所以万一我发布了一个快速修复。
原始代码:
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;固定代码:
discFormatData = new MsftDiscFormat2Data { Recorder = discRecorder };
fileSystemImage = new MsftFileSystemImage();
fileSystemImage.ChooseImageDefaults(discRecorder);
if (!discFormatData.MediaHeuristicallyBlank)
{
fileSystemImage.MultisessionInterfaces = discFormatData.MultisessionInterfaces;
fileSystemImage.ImportFileSystem();
}
Int64 freeMediaBlocks = fileSystemImage.FreeMediaBlocks;发布于 2012-09-14 13:03:00
如果您知道空闲/已使用的块和存储卷的总大小(忽略已使用/空闲的空间),那么您可以计算每个块的大小,然后计算出其余的。
block size = total size / (blocks used + blocks free)
free space = size per block * blocks free如果你发现这个块状的尺寸不是1K,我会很惊讶
发布于 2012-09-14 15:49:17
通过IMAPI - IWriteEngine2::get_BytesPerSector
http://msdn.microsoft.com/en-us/library/windows/desktop/aa832661(v=vs.85).aspx
该项目使用托管IMAPI2包装器来简化生活- http://www.codeproject.com/Articles/24544/Burning-and-Erasing-CD-DVD-Blu-ray-Media-with-C-an。
https://stackoverflow.com/questions/12423357
复制相似问题