|
Dieser Artikel wurde manuell übersetzt. Bewegen Sie den Mauszeiger über die Sätze im Artikel, um den Originaltext anzuzeigen.
|
Übersetzung
Original
|
BinaryWriter.Write-Methode (Byte)
Assembly: mscorlib (in mscorlib.dll)
Parameter
- value
- Typ: System.Byte
Das zu schreibende Byte ohne Vorzeichen.
| Ausnahme | Bedingung |
|---|---|
| IOException | |
| ObjectDisposedException |
UTF-7 ISO-2022-JP ISCII
using System; using System.IO; class BinaryRW { static void Main() { int i = 0; // Create random data to write to the stream. byte[] writeArray = new byte[1000]; new Random().NextBytes(writeArray); BinaryWriter binWriter = new BinaryWriter(new MemoryStream()); BinaryReader binReader = new BinaryReader(binWriter.BaseStream); try { // Write the data to the stream. Console.WriteLine("Writing the data."); for(i = 0; i < writeArray.Length; i++) { binWriter.Write(writeArray[i]); } // Set the stream position to the beginning of the stream. binReader.BaseStream.Position = 0; // Read and verify the data from the stream. for(i = 0; i < writeArray.Length; i++) { if(binReader.ReadByte() != writeArray[i]) { Console.WriteLine("Error writing the data."); return; } } Console.WriteLine("The data was written and verified."); } // Catch the EndOfStreamException and write an error message. catch(EndOfStreamException e) { Console.WriteLine("Error writing the data.\n{0}", e.GetType().Name); } } }
Windows 7, Windows Vista SP1 oder höher, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core wird nicht unterstützt), Windows Server 2008 R2 (Server Core wird mit SP1 oder höher unterstützt), Windows Server 2003 SP2
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen für .NET Framework.