Writing to a tape drive using C#/.NET
I'm trying to write a backup program that uses a tape drive.
I've downloaded http://www.codeproject.com/KB/system/Tape_drive_operator.aspx and that seems to do what I'm after but I get an error message when calling the following:
public void Write(long startPos, byte[] stream)
{
// Get number of blocks that will be nned to perform write
uint numberOfBlocks = GetBlocksNumber(stream.Length);
// Updates tape's current position
SetTapePosition(startPos);
byte[] arrayToWrite = new byte[numberOfBlocks * BlockSize];
Array.Copy(stream, arrayToWrite, stream.Length);
// Write data to the device
m_stream.Write(arrayToWrite, 0, arrayToWrite.Length);
m_stream.Flush();
}
It loads the tape but when I write the data the m_stream.Flush()
command bombs out with 开发者_C百科the following error message:
IO operation will not work. Most likely the file will become too long or the handle was not opened to support synchronous IO operations.
Has anyone else experienced this issue before?
Cheers, Blakey
Open the file handle with the correct block size for the device.
精彩评论