當前位置: 首頁>>代碼示例>>C#>>正文


C# BinaryWriter.Write方法代碼示例

本文整理匯總了C#中BinaryWriter.Write方法的典型用法代碼示例。如果您正苦於以下問題:C# BinaryWriter.Write方法的具體用法?C# BinaryWriter.Write怎麽用?C# BinaryWriter.Write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在BinaryWriter的用法示例。


在下文中一共展示了BinaryWriter.Write方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Save

	public override void Save(BinaryWriter bw) {
		base.Save(bw);
		bw.Write(dir == 1);
		bw.Write((byte)height);
		bw.Write(sin);
		bw.Write(sinSpeed);
	}
開發者ID:mugmickey,項目名稱:Terraria-tConfig-Mods,代碼行數:7,代碼來源:EffectFireflyHover.cs

示例2: Serialize

	public static byte[] Serialize(Account account)
	{
		using (MemoryStream stream = new MemoryStream())
		using (BinaryWriter writer = new BinaryWriter(stream))
		{
			try
			{
				writer.Write(account.Email);
				writer.Write(account.Username);
				writer.Write((byte)account.Characters.Length);
				for (int i = 0; i < account.Characters.Length; i++)
				{
					byte[] bytes = Serialize(account.Characters[i]);
					writer.Write(bytes.Length);
					writer.Write(bytes);
				}
				return stream.ToArray();
			}
			catch (Exception e)
			{
				Debug.Log("Exception at Serialization.Serialize: " + e.Message);
				return new byte[0];
			}

		}
	}
開發者ID:dallinnguyen,項目名稱:Pokemon,代碼行數:26,代碼來源:Serialization.cs

示例3: DrawImage

	private void DrawImage(VideoFrameType type)
	{
		Stream str = new MemoryStream();
		BinaryWriter writer = new BinaryWriter(str);
		// LITTLE ENDIAN!!
		writer.Write(new byte[] { 0x42, 0x4D });
		writer.Write((int)(type.managedData.Length + 0x36));
		writer.Write((int)0);
		writer.Write((int)0x36);
		writer.Write((int)40);
		writer.Write((int)type.width);
		writer.Write((int)type.height);
		writer.Write((short)1);
		writer.Write((short)24);
		writer.Write((int)0);
		writer.Write((int)type.managedData.Length);
		writer.Write((int)3780);
		writer.Write((int)3780);
		writer.Write((int)0);
		writer.Write((int)0);
		for (int y = type.height - 1; y >= 0; y--)
			writer.Write(type.managedData, y * type.linesize, type.width * 3);
		writer.Flush();
		writer.Seek(0, SeekOrigin.Begin);
		Bitmap bitmap = new Bitmap(str);
		g.DrawImage(bitmap, 0, 0, mainDraw.WidthRequest, mainDraw.HeightRequest);
		writer.Close();

	}
開發者ID:crazyender,項目名稱:FFMPEG.net,代碼行數:29,代碼來源:MainWindow.cs

示例4: Save

 public void Save(BinaryWriter Stream)
 {
     Stream.Write(PathTexture, true);
     Stream.Write(PathNormalmap, true);
     Stream.Write(ScaleTexture);
     Stream.Write(ScaleNormalmap);
 }
開發者ID:ZoneBeat,項目名稱:FAForeverMapEditor,代碼行數:7,代碼來源:Layer.cs

示例5: Main

	public static int Main () {
		MemoryStream mr = new MemoryStream();
		BinaryWriter wr = new BinaryWriter(mr);

		wr.Write ((byte) 1);
		wr.Write ((int) 1);
		wr.Write ((int) -1);

		byte [] arr = mr.ToArray();

		Console.Write ("Array (should be: 1 1 0 0 0 ff ff ff ff): ");

		for (int a = 0; a != arr.Length; a++)
			Console.Write(arr[a].ToString("x") + " ");		

		Console.WriteLine();

		if (arr.Length != 9)
			return 4;

		if (arr[0] != 1) 
			return 1;

		if (arr[1] != 1 && arr[2] != 0 && arr[3] != 0 && arr[4] != 0)
			return 2;

		if (arr[5] != 0xff && arr[6] != 0xff && arr[7] != 0xff && arr[8] != 0xff)
			return 3;
	
		Console.WriteLine("test-ok");

		return 0;
	}
開發者ID:Zman0169,項目名稱:mono,代碼行數:33,代碼來源:binwritter.cs

示例6: Write

 public void Write(BinaryWriter w)
 {
     //if (w == null) throw new ArgumentNullException("w");
     w.Write(FResult.ToString());
     w.Write(FSeparator);
     w.Write(FEmpty);
 }
開發者ID:APouchkov,項目名稱:ExtendedStoredProcedures,代碼行數:7,代碼來源:Strings.cs

示例7: WriteBlock

 public void WriteBlock(Stream stream)
 {
     BinaryWriter writer = new BinaryWriter(stream);
     writer.Write(Tag);
     writer.Write(Size);
     writer.Write(Data);
 }
開發者ID:dotnet,項目名稱:corefx,代碼行數:7,代碼來源:ZipBlocks.cs

示例8: Save

            // Binary save
            public void Save(string filename)
            {
                FileStream binFile = new FileStream(filename, FileMode.Create, FileAccess.ReadWrite);
                //			ICSharpCode.SharpZipLib.GZip.GZipOutputStream gz = new ICSharpCode.SharpZipLib.GZip.GZipOutputStream(binFile);
                //			BinaryWriter writer = new BinaryWriter(gz);
                BinaryWriter writer = new BinaryWriter(binFile);

                writer.Write(BinaryHeaderVersionString);
                writer.Write(mFormat);

                // Write out string table
                writer.Write( stringTable.Count );
                for (int i = 0, e = stringTable.Count; i < e; i++)
                {
                    writer.Write( stringTable[i] );
                }

                // Write out categories
                writer.Write( categories.Count );
                foreach (string i in categories)
                {
                    writer.Write( i );
                }

                // Write out heap ranges.
                writer.Write( mAllocators.Count );
                foreach (LogEntryAllocators e in mAllocators)
                {
                    writer.Write(e.mName);
                    writer.Write(e.mStartAddress);
                    writer.Write(e.mEndAddress);
                }

                //Write out DataFields.
                writer.Write(field.Count);
                foreach (string e in field)
                {
                    writer.Write(e);
                }

                writer.Write( log.Count );
                for (int i = 0, e = log.Count; i < e; i++)
                {
                    LogEntry logentry = (LogEntry)(log[i]);
                    writer.Write( logentry.type );
                    writer.Write( logentry.category );
                    writer.Write( logentry.allocator );
                    writer.Write( logentry.address );
                //	writer.Write( logentry.reqSize );
                    writer.Write( logentry.allocSize );
                    writer.Write( logentry.alignment );
                    writer.Write( logentry.nameString );
                    writer.Write( logentry.stackTraceString );
                    writer.Write( logentry.number );
                }

                writer.Close();
                binFile.Close();
            }
開發者ID:arjangcore,項目名稱:MemoryCompare,代碼行數:60,代碼來源:Log.cs

示例9: Write

 public void Write( BinaryWriter w )
 {
     w.Write( this.values.Count );
     foreach ( string s in this.values )
     {
         w.Write( s );
     }
 }
開發者ID:ohri,項目名稱:netba,代碼行數:8,代碼來源:TradeAggregator.cs

示例10: Save

	public void Save(BinaryWriter bw) {
		bw.Write(list.Count);
		foreach (TileFirefly tf in list) {
			bw.Write(tf.x);
			bw.Write(tf.y);
			SaveOne(bw,tf.firefly);
		}
	}
開發者ID:mugmickey,項目名稱:Terraria-tConfig-Mods,代碼行數:8,代碼來源:TileFireflyHandler.cs

示例11: SaveNormal

 public void SaveNormal(BinaryWriter Stream)
 {
     string Path = PathNormalmap.Replace("\\", "/");
     if (!string.IsNullOrEmpty(Path) & !Path.StartsWith("/"))
         Path = "/" + Path;
     Stream.Write(Path, true);
     Stream.Write(ScaleNormalmap);
 }
開發者ID:ZoneBeat,項目名稱:FAForeverMapEditor,代碼行數:8,代碼來源:Layer.cs

示例12: SaveAlbedo

 public void SaveAlbedo(BinaryWriter Stream)
 {
     string Path = PathTexture.Replace("\\", "/");
     if (!string.IsNullOrEmpty(Path) & !Path.StartsWith("/"))
         Path = "/" + Path;
     Stream.Write(Path, true);
     Stream.Write(ScaleTexture);
 }
開發者ID:ZoneBeat,項目名稱:FAForeverMapEditor,代碼行數:8,代碼來源:Layer.cs

示例13: Write

 public void Write(BinaryWriter w)
 {
     w.Write(_list.Count);
     foreach(double v in _list)
     {
         w.Write(v);
     }
 }
開發者ID:ben-thul,項目名稱:SQLCLR,代碼行數:8,代碼來源:NaiveSum.cs

示例14: Main

 public static void Main(string[] args)
 {
     if (args.Length != 2) {
       Console.Error.WriteLine("Usage: SHS.SCC1 <leader> <store>");
     } else {
       var sw = Stopwatch.StartNew();
       var store = new Service(args[0]).OpenStore(Guid.Parse(args[1]));
       long numUids = store.NumUrls();
       var bv = new BitVector(numUids);  // All false at creation
       var stk = new LongStack(1 << 23, "scc");
       foreach (long u in store.Uids()) {
     if (!bv[store.UidToLid(u)]) {
       Frame frame = new Frame(null, u, store, Dir.Fwd, bv);
       while (frame != null) {
         while (frame.linkPos < frame.links.Length) {
           long v = frame.links[frame.linkPos++];
           if (!bv[store.UidToLid(v)]) {
             frame = new Frame(frame, v, store, Dir.Fwd, bv);
           }
         }
         stk.Push(frame.uid);
         frame = frame.parent;
       }
     }
       }
       using (var sccWr = new BinaryWriter(new BufferedStream(new FileStream("scc-main.bin", FileMode.Create, FileAccess.Write)))) {
     using (var idxWr = new BinaryWriter(new BufferedStream(new FileStream("scc-index.bin", FileMode.Create, FileAccess.Write)))) {
       long numSCCs = 0;
       long sccPos = 0;
       bv.SetAll(false);
       for (long i = 0; i < numUids; i++) {
         long u = stk.Pop();
         if (!bv[store.UidToLid(u)]) {
           numSCCs++;
           long sccSize = 0;
           Frame frame = new Frame(null, u, store, Dir.Bwd, bv);
           while (frame != null) {
             while (frame.linkPos < frame.links.Length) {
               long v = frame.links[frame.linkPos++];
               if (!bv[store.UidToLid(v)]) {
                 frame = new Frame(frame, v, store, Dir.Bwd, bv);
               }
             }
             sccWr.Write(frame.uid);
             sccSize++;
             frame = frame.parent;
           }
           idxWr.Write(sccSize);
           idxWr.Write(sccPos);
           sccPos += sccSize;
         }
       }
     }
       }
       store.Close();
       Console.WriteLine("Done. Job took {0} seconds.", 0.001 * sw.ElapsedMilliseconds);
     }
 }
開發者ID:pszmyd,項目名稱:SHS,代碼行數:58,代碼來源:SCC1.cs

示例15: Save

	public override void Save(BinaryWriter bw) {
		base.Save(bw);
		NetworkHelper.Write(bw,color);
		bw.Write(rot1);
		bw.Write(rotSpeed1);
		bw.Write(rot2);
		bw.Write(rotSpeed2);
		bw.Write(chaos);
	}
開發者ID:mugmickey,項目名稱:Terraria-tConfig-Mods,代碼行數:9,代碼來源:EffectFireflyCorrupt.cs


注:本文中的BinaryWriter.Write方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。