本文整理汇总了C#中System.IO.BinaryWriter.Write方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.BinaryWriter.Write方法的具体用法?C# System.IO.BinaryWriter.Write怎么用?C# System.IO.BinaryWriter.Write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.BinaryWriter
的用法示例。
在下文中一共展示了System.IO.BinaryWriter.Write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BaseField_Leave
public override void BaseField_Leave(object sender, EventArgs e)
{
System.IO.BinaryWriter bw = new System.IO.BinaryWriter(meta.MS);
if (((WinMetaEditor)this.ParentForm).checkSelectionInCurrentTag())
bw.BaseStream.Position = this.offsetInMap - meta.offset;
bw.Write((short)this.sidIndexer);
bw.Write((byte) 0);
bw.Write((byte)map.Strings.Length[this.sidIndexer]);
/*
// Check for typed value
SID sid = (SID)(sender);
if (sid.comboBox1.Text != map.Strings.Name[sid.sidIndexer])
{
for (int i = 0; i < map.Strings.Name.Length; i++)
if (map.Strings.Name[i].ToLower() == sid.comboBox1.Text.ToLower())
{
sid.sidIndexer = i;
break;
}
sid.comboBox1.Text = map.Strings.Name[sid.sidIndexer];
}
*/
//if (this.AutoSave)
// this.Save();
}
示例2: packMe
public override byte[] packMe()
{
System.IO.BinaryWriter writer = new System.IO.BinaryWriter(new System.IO.MemoryStream());
writer.Write(message);
writer.Write(bounced);
return ((System.IO.MemoryStream)writer.BaseStream).GetBuffer();
}
示例3: packMe
public override byte[] packMe()
{
System.IO.BinaryWriter writer = new System.IO.BinaryWriter(new System.IO.MemoryStream());
writer.Write(frompos);
writer.Write(topos);
return ((System.IO.MemoryStream)writer.BaseStream).GetBuffer();
}
示例4: GetMessageBody
public override byte[] GetMessageBody()
{
System.IO.MemoryStream ms = new System.IO.MemoryStream ();
System.IO.BinaryWriter bw = new System.IO.BinaryWriter (ms);
bw.Write (userData.Length);
foreach (var ud in userData)
bw.Write (ud.GetMessageBody ());
return ms.ToArray ();
}
示例5: Save
public void Save ( System.IO.Stream stream ) {
var writer = new System.IO.BinaryWriter ( stream );
writer.Write (dict.Count);
foreach (KeyValuePair<string,ZipEntry> pair in dict) {
writer.Write (pair.Key);
writer.Write (pair.Value.bytes.Length);
writer.Write (pair.Value.bytes);
}
}
示例6: SaveToFile
public void SaveToFile(string fileName)
{
using(var writer = new System.IO.BinaryWriter(System.IO.File.OpenWrite(fileName)))
{
writer.Write(_header);
writer.Write(_bytes);
writer.Flush();
}
}
示例7: button1_Click
// ***** Start pairing (play sound)*****
private void button1_Click(object sender, EventArgs e)
{
if (clsHvcw.GenerateSound(textSSID.Text, textPassword.Text, txtToken) == true)
{
// Read sound file
byte[] buf = System.IO.File.ReadAllBytes(clsHvcw.SoundFile);
// Stop when sound playing
if (player != null)
StopSound();
player = new System.Media.SoundPlayer();
// Wav header definition
WAVHDR wavHdr = new WAVHDR();
uint fs = 8000;
wavHdr.formatid = 0x0001; // PCM uncompressed
wavHdr.channel = 1; // ch=1 mono
wavHdr.fs = fs; // Frequency
wavHdr.bytespersec = fs * 2; // 16bit
wavHdr.blocksize = 2; // 16bit mono so block size (byte/sample x # of channels) is 2
wavHdr.bitspersample = 16; // bit/sample
wavHdr.size = (uint)buf.Length; // Wave data byte number
wavHdr.fileSize = wavHdr.size + (uint)Marshal.SizeOf(wavHdr); // Total byte number
// Play sound through memory stream
System.IO.MemoryStream memoryStream = new System.IO.MemoryStream((int)wavHdr.fileSize);
System.IO.BinaryWriter bWriter = new System.IO.BinaryWriter(memoryStream);
// Write Wav header
foreach (byte b in wavHdr.getByteArray())
{
bWriter.Write(b);
}
// Write PCM data
foreach (byte data in buf)
{
bWriter.Write(data);
}
bWriter.Flush();
memoryStream.Seek(0, System.IO.SeekOrigin.Begin);
player.Stream = memoryStream;
// Async play
player.Play();
// Wait until sound playing is over with following:
// player.PlaySync();
}
else
{
MessageBox.Show("Pairing sound creation failed", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
示例8: calcbodysize
public override void calcbodysize()
{
System.IO.BinaryWriter bw = new System.IO.BinaryWriter(new System.IO.MemoryStream());
bw.Write(generator);
bw.Write(objectInformation.Count);
for (int i = 0; i < objectInformation.Count; i++)
{
objectInformation[i].ToStream(bw);
}
camera.toStream(bw);
size = Convert.ToInt32(bw.BaseStream.Length);
}
示例9: Save
public override void Save(string filename, Endogine.ColorEx.Palette palette)
{
System.IO.BinaryWriter writer = new System.IO.BinaryWriter(new System.IO.FileStream(filename, System.IO.FileMode.OpenOrCreate));
foreach (KeyValuePair<string, ColorEx.ColorBase> kv in palette)
{
//Vector4 v = color.VectorRGBA;
System.Drawing.Color c = kv.Value.ColorRGBA;
writer.Write((byte)(int)c.R);
writer.Write((byte)(int)c.G);
writer.Write((byte)(int)c.B);
}
}
示例10: packMe
public override byte[] packMe()
{
System.IO.BinaryWriter writer = new System.IO.BinaryWriter(new System.IO.MemoryStream());
writer.Write(players.Length);
for (int i = 0; i < players.Length; i++)
{
writer.Write(players[i].color.ToArgb());
writer.Write(players[i].name);
}
return ((System.IO.MemoryStream)writer.BaseStream).GetBuffer();
}
示例11: MouseEvent
public void MouseEvent(MouseEventFlags flags, int x, int y)
{
var messageStream = new System.IO.MemoryStream();
var messageWriter = new System.IO.BinaryWriter(messageStream);
messageWriter.Write(0);
messageWriter.Write((uint)flags);
messageWriter.Write(x);
messageWriter.Write(y);
messageWriter.Write(0);
SendMessage(messageStream.ToArray());
}
示例12: CreateChannelID
static public Guid CreateChannelID(Guid bcid, string channel_name, string genre, string source)
{
var stream = new System.IO.MemoryStream();
using (var writer = new System.IO.BinaryWriter(stream)) {
var bcid_hash = System.Security.Cryptography.SHA512.Create().ComputeHash(bcid.ToByteArray());
writer.Write(bcid_hash);
writer.Write(channel_name);
writer.Write(genre);
writer.Write(source);
}
var channel_hash = System.Security.Cryptography.MD5.Create().ComputeHash(stream.ToArray());
return new Guid(channel_hash);
}
示例13: btnExport_Click
private void btnExport_Click(object sender, EventArgs e)
{
System.IO.BinaryWriter bw = new System.IO.BinaryWriter(System.IO.File.Open("export.txt", System.IO.FileMode.Create));
bw.Write(width);//columns
bw.Write(height);//rows
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
bw.Write(mapData[x, y]);
}
}
bw.Close();
}
示例14: CreateSelfSignCertificate
static void CreateSelfSignCertificate(CertOption option)
{
var fileName = option.CertFileName;
var subject = option.Subject;
var password = option.Password;
try
{
var securePassword = Certificate.ConvertSecureString(password);
var startDate = DateTime.Now;
var endDate = startDate.AddYears(option.Years);
var certData = Certificate.CreateSelfSignCertificatePfx(subject, startDate, endDate, securePassword);
using (var writer = new System.IO.BinaryWriter(System.IO.File.Open(fileName, System.IO.FileMode.Create)))
{
writer.Write(certData);
writer.Flush();
writer.Close();
}
securePassword = Certificate.ConvertSecureString(password);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
示例15: Reset
public void Reset()
{
var messageStream = new System.IO.MemoryStream();
var messageWriter = new System.IO.BinaryWriter(messageStream);
messageWriter.Write(1);
SendMessage(messageStream.ToArray());
}