本文整理汇总了C#中System.IO.BinaryWriter.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.BinaryWriter.Dispose方法的具体用法?C# System.IO.BinaryWriter.Dispose怎么用?C# System.IO.BinaryWriter.Dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.BinaryWriter
的用法示例。
在下文中一共展示了System.IO.BinaryWriter.Dispose方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: calcbodysize
public override void calcbodysize()
{
System.IO.BinaryWriter bw = new System.IO.BinaryWriter(new System.IO.MemoryStream());
ToStream(bw);
size = Convert.ToInt32(bw.BaseStream.Length);
bw.Close();
bw.Dispose();
}
示例2: getData
public byte[] getData()
{
byte[] result = new byte[getNumSamples() * channels * (bitDepth / 8)];
System.IO.MemoryStream ms = new System.IO.MemoryStream(result);
System.IO.BinaryWriter wr = new System.IO.BinaryWriter(ms);
if (bitDepth == 16) {
for (int i = 0; i < getNumSamples(); i++) {
for (int c = 0; c < channels; c++) {
//assuming signed
wr.Write((short)(samples[c][i] * 32768));
}
}
} else if (bitDepth == 8) {
for (int i = 0; i < getNumSamples(); i++) {
for (int c = 0; c < channels; c++) {
//assuming unsigned
wr.Write((byte)(samples[c][i] * 128 + 128));
}
}
}
wr.Dispose();
ms.Dispose();
return result;
}
示例3: button1_Click
//save
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text.Length < 5)
{
MessageBox.Show("too short nbame");
return;
}
SaveFileDialog sfd = new SaveFileDialog();
if (sfd.ShowDialog() != System.Windows.Forms.DialogResult.OK)
return;
ResourceCollectorXNA.Engine.EngineLevel level = GameEngine.Instance.gameLevel;
level.FillContent();
System.IO.BinaryWriter bw = new System.IO.BinaryWriter(new System.IO.FileStream(sfd.FileName, System.IO.FileMode.OpenOrCreate));
level.levelContent.savebody(bw);
bw.Flush();
bw.Close();
bw.Dispose();
}