当前位置: 首页>>代码示例>>C#>>正文


C# System.IO.BinaryWriter.Write方法代码示例

本文整理汇总了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();
        }
开发者ID:nolenfelten,项目名称:Blam_BSP,代码行数:27,代码来源:StringBox.cs

示例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();
 }
开发者ID:ds0nt,项目名称:group-15-3,代码行数:7,代码来源:ChatMessage.cs

示例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();
 }
开发者ID:ds0nt,项目名称:group-15-3,代码行数:7,代码来源:Move.cs

示例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 ();
 }
开发者ID:vebin,项目名称:BD2,代码行数:9,代码来源:EnumerateUsersResponseMessage.cs

示例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);
			}
		}
开发者ID:JtheSpaceC,项目名称:Breaking-The-Rules,代码行数:9,代码来源:SimpleZipReplacement.cs

示例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();
     }
 }
开发者ID:ArchSlave,项目名称:Fractal,代码行数:9,代码来源:NetPbm.cs

示例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);
            }
        }
开发者ID:Qrain,项目名称:photo-tool,代码行数:58,代码来源:Sound.cs

示例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);
 }
开发者ID:KatekovAnton,项目名称:ResourceCollector,代码行数:12,代码来源:LevelContent.cs

示例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);
     }
 }
开发者ID:timdetering,项目名称:Endogine,代码行数:12,代码来源:Act.cs

示例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();
        }
开发者ID:ds0nt,项目名称:group-15-3,代码行数:12,代码来源:GameStart.cs

示例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());
        }
开发者ID:DrReiz,项目名称:DrReiz.Robo-Gamer,代码行数:12,代码来源:MouseClient.cs

示例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);
 }
开发者ID:kumaryu,项目名称:peercaststation,代码行数:13,代码来源:BroadcastChannel.cs

示例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();
        }
开发者ID:Hibchibbler,项目名称:SimpleGame,代码行数:15,代码来源:Form1.cs

示例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);
            }
        }
开发者ID:UrmnafBortHyuga,项目名称:csharplesson,代码行数:26,代码来源:Program.cs

示例15: Reset

 public void Reset()
 {
     var messageStream = new System.IO.MemoryStream();
     var messageWriter = new System.IO.BinaryWriter(messageStream);
     messageWriter.Write(1);
     SendMessage(messageStream.ToArray());
 }
开发者ID:DrReiz,项目名称:DrReiz.Robo-Gamer,代码行数:7,代码来源:MouseClient.cs


注:本文中的System.IO.BinaryWriter.Write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。