本文整理汇总了C#中System.IO.Stream.Write方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.Stream.Write方法的具体用法?C# System.IO.Stream.Write怎么用?C# System.IO.Stream.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.Stream
的用法示例。
在下文中一共展示了System.IO.Stream.Write方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GMKOut
public GMKOut(System.IO.Stream source)
{
s = source;
Random r = new Random(Environment.TickCount);
int junk1 = 0; // r.Next(1, 3000) + 123;
int junk2 = 0; // r.Next(1, 3000) + 321;
int seed = 0xF8; // r.Next(1, 25600) + 3328;
extra = (junk1 + junk2 + 3) * 4;
table = GenerateSwapTable(seed);
s.Write(new byte[] { 0x91, 0xD5, 0x12, 0x00, 0xBD, 0x02, 0x00, 0x00 }, 0, 8);
s.Write(BitConverter.GetBytes(junk1), 0, 4);
s.Write(BitConverter.GetBytes(junk2), 0, 4);
for (int i = 0; i < junk1; i++)
s.Write(BitConverter.GetBytes(r.Next(1, 3000)), 0, 4);
s.Write(BitConverter.GetBytes(seed), 0, 4);
for (int i = 0; i < junk2; i++)
s.Write(BitConverter.GetBytes(r.Next(1, 3000)), 0, 4);
pos = s.Position;
}
示例2: ChecksumFileWriter
/// <summary>
/// Constructs a new CheckSum file
/// <param name="blocklength">The length of a single block</param>
/// <param name="stronglength">The number of bytes in the MD4 checksum</param>
/// <param name="outputstream">The stream into which the checksum data is written</param>
/// </summary>
public ChecksumFileWriter(System.IO.Stream outputstream, int blocklength, int stronglength)
{
if (outputstream == null)
throw new ArgumentNullException("outputstream");
m_blocklen = blocklength;
m_stronglen = stronglength;
m_outstream = outputstream;
m_hashAlgorithm = MD4Helper.Create();
m_hashAlgorithm.Initialize();
m_outstream.Write(RDiffBinary.SIGNATURE_MAGIC, 0, RDiffBinary.SIGNATURE_MAGIC.Length);
m_outstream.Write(RDiffBinary.FixEndian(BitConverter.GetBytes(m_blocklen)), 0, 4);
m_outstream.Write(RDiffBinary.FixEndian(BitConverter.GetBytes(m_stronglen)), 0, 4);
}
示例3: Open
/// <summary> Open a RIFF STREAM.
/// </summary>
public virtual int Open(System.IO.Stream stream, int NewMode)
{
int retcode = DDC_SUCCESS;
if (fmode != RFM_UNKNOWN)
{
retcode = Close();
}
if (retcode == DDC_SUCCESS)
{
switch (NewMode)
{
case RFM_WRITE:
try
{
//file = SupportClass.RandomAccessFileSupport.CreateRandomAccessFile(Filename, "rw");
file = stream;
try
{
// Write the RIFF header...
// We will have to come back later and patch it!
sbyte[] br = new sbyte[8];
br[0] = (sbyte) ((SupportClass.URShift(riff_header.ckID, 24)) & 0x000000FF);
br[1] = (sbyte) ((SupportClass.URShift(riff_header.ckID, 16)) & 0x000000FF);
br[2] = (sbyte) ((SupportClass.URShift(riff_header.ckID, 8)) & 0x000000FF);
br[3] = (sbyte) (riff_header.ckID & 0x000000FF);
sbyte br4 = (sbyte) ((SupportClass.URShift(riff_header.ckSize, 24)) & 0x000000FF);
sbyte br5 = (sbyte) ((SupportClass.URShift(riff_header.ckSize, 16)) & 0x000000FF);
sbyte br6 = (sbyte) ((SupportClass.URShift(riff_header.ckSize, 8)) & 0x000000FF);
sbyte br7 = (sbyte) (riff_header.ckSize & 0x000000FF);
br[4] = br7;
br[5] = br6;
br[6] = br5;
br[7] = br4;
file.Write(SupportClass.ToByteArray(br), 0, 8);
fmode = RFM_WRITE;
}
catch (System.IO.IOException ioe)
{
file.Close();
fmode = RFM_UNKNOWN;
}
}
catch (System.IO.IOException ioe)
{
fmode = RFM_UNKNOWN;
retcode = DDC_FILE_ERROR;
}
break;
case RFM_READ:
try
{
file = stream;
//file = SupportClass.RandomAccessFileSupport.CreateRandomAccessFile(Filename, "r");
try
{
// Try to read the RIFF header...
sbyte[] br = new sbyte[8];
SupportClass.ReadInput(file, ref br, 0, 8);
fmode = RFM_READ;
riff_header.ckID = ((br[0] << 24) & (int) SupportClass.Identity(0xFF000000)) | ((br[1] << 16) & 0x00FF0000) | ((br[2] << 8) & 0x0000FF00) | (br[3] & 0x000000FF);
riff_header.ckSize = ((br[4] << 24) & (int) SupportClass.Identity(0xFF000000)) | ((br[5] << 16) & 0x00FF0000) | ((br[6] << 8) & 0x0000FF00) | (br[7] & 0x000000FF);
}
catch (System.IO.IOException ioe)
{
file.Close();
fmode = RFM_UNKNOWN;
}
}
catch (System.IO.IOException ioe)
{
fmode = RFM_UNKNOWN;
retcode = DDC_FILE_ERROR;
}
break;
default:
retcode = DDC_INVALID_CALL;
break;
}
}
return retcode;
}
示例4: CopyStream
private static void CopyStream(Stream input, Stream output)
{
byte[] buffer = new byte[32768];
while (true)
{
int read = input.Read(buffer, 0, buffer.Length);
if (read <= 0)
return;
output.Write(buffer, 0, read);
}
}