本文整理汇总了C#中System.IO.BinaryWriter类的典型用法代码示例。如果您正苦于以下问题:C# System.IO.BinaryWriter类的具体用法?C# System.IO.BinaryWriter怎么用?C# System.IO.BinaryWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.IO.BinaryWriter类属于命名空间,在下文中一共展示了System.IO.BinaryWriter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: 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
示例2: 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
示例3: Assemble
public static void Assemble(string infile, string outfile, string origin)
{
CurrentNdx = 0;
AsLength = Convert.ToUInt16(origin, 16);
IsEnd = false;
ExecutionAddress = 0;
LabelTable = new System.Collections.Hashtable(50);
System.IO.BinaryWriter output;
System.IO.TextReader input;
System.IO.FileStream fs = new System.IO.FileStream(outfile, System.IO.FileMode.Create);
output = new System.IO.BinaryWriter(fs);
input = System.IO.File.OpenText(infile);
SourceProgram = input.ReadToEnd();
input.Close();
output.Write('B');
output.Write('3');
output.Write('2');
output.Write(Convert.ToUInt16(origin, 16));
output.Write((ushort)0);
Parse(output, origin);
output.Seek(5, System.IO.SeekOrigin.Begin);
output.Write(ExecutionAddress);
output.Close();
fs.Close();
}
开发者ID:samwho,项目名称:csvm,代码行数:30,代码来源:Assembler.cs
示例4: FormaterBuffer
public FormaterBuffer(int size)
{
mBuffer = new byte[size];
mStream = new System.IO.MemoryStream(mBuffer);
mReader = new System.IO.BinaryReader(mStream);
mWriter = new System.IO.BinaryWriter(mStream);
}
开发者ID:qcjxberin,项目名称:CacheDB,代码行数:7,代码来源:FormaterBuffer.cs
示例5: 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
示例6: 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;
try
{
this.value = int.Parse(this.comboBox1.Text);
}
catch
{
this.value = this.comboBox1.SelectedIndex;
}
switch (this.enumType)
{
case 8:
{
bw.Write(Convert.ToByte(this.value));
break;
}
case 16:
{
bw.Write(Convert.ToInt16(this.value));
break;
}
case 32:
{
bw.Write(this.value);
break;
}
}
}
开发者ID:nolenfelten,项目名称:Blam_BSP,代码行数:32,代码来源:Enums.cs
示例7: 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
示例8: SerializeVoxelAreaData
public static byte[] SerializeVoxelAreaData (VoxelArea v) {
#if !ASTAR_RECAST_CLASS_BASED_LINKED_LIST
System.IO.MemoryStream stream = new System.IO.MemoryStream();
System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream);
writer.Write (v.width);
writer.Write (v.depth);
writer.Write (v.linkedSpans.Length);
for (int i=0;i<v.linkedSpans.Length;i++) {
writer.Write(v.linkedSpans[i].area);
writer.Write(v.linkedSpans[i].bottom);
writer.Write(v.linkedSpans[i].next);
writer.Write(v.linkedSpans[i].top);
}
//writer.Close();
writer.Flush();
Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile();
stream.Position = 0;
zip.AddEntry ("data",stream);
System.IO.MemoryStream stream2 = new System.IO.MemoryStream();
zip.Save(stream2);
byte[] bytes = stream2.ToArray();
stream.Close();
stream2.Close();
return bytes;
#else
throw new System.NotImplementedException ("This method only works with !ASTAR_RECAST_CLASS_BASED_LINKED_LIST");
#endif
}
开发者ID:SpacesAdventure,项目名称:Kio-2,代码行数:31,代码来源:VoxelClasses.cs
示例9: split
public static void split(string input_path, string dir_path, int nb)
{
System.IO.FileStream inf = new System.IO.FileStream(input_path, System.IO.FileMode.Open, System.IO.FileAccess.Read);
System.IO.BinaryReader reader = new System.IO.BinaryReader(inf);
System.IO.BinaryWriter[] writers = new System.IO.BinaryWriter[nb];
for (int x = 0; x < nb; x++)
{
writers[x] = new System.IO.BinaryWriter(new System.IO.FileStream(dir_path + "/part_" + (x + 1) + ".ACDC",
System.IO.FileMode.Create,
System.IO.FileAccess.Write));
}
int i = 0;
while (reader.PeekChar() != -1)
{
writers[i % nb].Write(reader.ReadChar());
i++;
}
for (int j=0; j<nb; j++)
{
writers[j].Close();
}
}
开发者ID:Ardawo,项目名称:TPC-,代码行数:26,代码来源:Splitter.cs
示例10: PNGtoBIN
public static void PNGtoBIN(string path_in, string path_out, string[] param = null)
{
Image png = Image.FromFile(path_in);
Bitmap bmp = new Bitmap(png);
if ((png.Width != 128) && (png.Height != 32))
return;
int tiles_w = png.Width / 4;
int tiles_h = png.Height / 8;
ushort[] binary = new ushort[256];
for (int y = 0; y < tiles_h; y++)
{
for (int x = 0; x < tiles_w; x++)
{
ushort[] tile = new ushort[2];
for (int iY = 0; iY < 8; iY++)
{
for (int iX = 0; iX < 4; iX++)
{
Color color = bmp.GetPixel(x * 4 + iX, y * 8 + iY);
if (color.R + color.G + color.B > 0x0100)
tile[(iY / 4)] |= (ushort)(1 << ((iY % 4) * 4 + iX));
}
}
binary[y * tiles_w * 2 + x * 2 + 0] = tile[0];
binary[y * tiles_w * 2 + x * 2 + 1] = tile[1];
}
}
System.IO.BinaryWriter writer = new System.IO.BinaryWriter(System.IO.File.Open(path_out, System.IO.FileMode.Create));
for (int i = 0; i < 256; i++)
writer.Write(binary[i]);
writer.Close();
}
开发者ID:ZaneDubya,项目名称:YCPU,代码行数:34,代码来源:Images.cs
示例11: 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
示例12: getPdfFile
public void getPdfFile(string fileName)
{
using (SqlConnection cn = new SqlConnection(ConnectionString))
{
cn.Open();
using (SqlCommand cmd = new SqlCommand($"select FileSource from PdfDocumentFiles where Name='{fileName}' ", cn))
{
using (SqlDataReader dr = cmd.ExecuteReader(System.Data.CommandBehavior.Default))
{
if (dr.Read())
{
byte[] fileData = (byte[])dr.GetValue(0);
using (System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite))
{
using (System.IO.BinaryWriter bw = new System.IO.BinaryWriter(fs))
{
bw.Write(fileData);
bw.Close();
}
}
}
dr.Close();
}
}
}
}
开发者ID:knitesh,项目名称:CodeSamples,代码行数:30,代码来源:PdfFileReader.cs
示例13: SerializeVoxelAreaCompactData
public static byte[] SerializeVoxelAreaCompactData (VoxelArea v) {
System.IO.MemoryStream stream = new System.IO.MemoryStream();
System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream);
writer.Write (v.width);
writer.Write (v.depth);
writer.Write (v.compactCells.Length);
writer.Write(v.compactSpans.Length);
writer.Write(v.areaTypes.Length);
for (int i=0;i<v.compactCells.Length;i++) {
writer.Write(v.compactCells[i].index);
writer.Write(v.compactCells[i].count);
}
for (int i=0;i<v.compactSpans.Length;i++) {
writer.Write(v.compactSpans[i].con);
writer.Write(v.compactSpans[i].h);
writer.Write(v.compactSpans[i].reg);
writer.Write(v.compactSpans[i].y);
}
for (int i=0;i<v.areaTypes.Length;i++) {
//TODO: RLE encoding
writer.Write(v.areaTypes[i]);
}
writer.Close();
return stream.ToArray();
}
开发者ID:henryj41043,项目名称:TheUnseen,代码行数:28,代码来源:VoxelClasses.cs
示例14: SerializeVoxelAreaData
public static byte[] SerializeVoxelAreaData (VoxelArea v) {
System.IO.MemoryStream stream = new System.IO.MemoryStream();
System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream);
writer.Write (v.width);
writer.Write (v.depth);
writer.Write (v.linkedSpans.Length);
for (int i=0;i<v.linkedSpans.Length;i++) {
writer.Write(v.linkedSpans[i].area);
writer.Write(v.linkedSpans[i].bottom);
writer.Write(v.linkedSpans[i].next);
writer.Write(v.linkedSpans[i].top);
}
//writer.Close();
writer.Flush();
Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile();
stream.Position = 0;
zip.AddEntry ("data",stream);
System.IO.MemoryStream stream2 = new System.IO.MemoryStream();
zip.Save(stream2);
byte[] bytes = stream2.ToArray();
stream.Close();
stream2.Close();
return bytes;
}
开发者ID:henryj41043,项目名称:TheUnseen,代码行数:27,代码来源:VoxelClasses.cs
示例15: SerializeVoxelAreaCompactData
public static byte[] SerializeVoxelAreaCompactData (VoxelArea v) {
#if !ASTAR_RECAST_CLASS_BASED_LINKED_LIST
System.IO.MemoryStream stream = new System.IO.MemoryStream();
System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream);
writer.Write (v.width);
writer.Write (v.depth);
writer.Write (v.compactCells.Length);
writer.Write(v.compactSpans.Length);
writer.Write(v.areaTypes.Length);
for (int i=0;i<v.compactCells.Length;i++) {
writer.Write(v.compactCells[i].index);
writer.Write(v.compactCells[i].count);
}
for (int i=0;i<v.compactSpans.Length;i++) {
writer.Write(v.compactSpans[i].con);
writer.Write(v.compactSpans[i].h);
writer.Write(v.compactSpans[i].reg);
writer.Write(v.compactSpans[i].y);
}
for (int i=0;i<v.areaTypes.Length;i++) {
//TODO: RLE encoding
writer.Write(v.areaTypes[i]);
}
writer.Close();
return stream.ToArray();
#else
throw new System.NotImplementedException ("This method only works with !ASTAR_RECAST_CLASS_BASED_LINKED_LIST");
#endif
}
开发者ID:SpacesAdventure,项目名称:Kio-2,代码行数:32,代码来源:VoxelClasses.cs
示例16: 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;
this.tagType = this.cbTagType.Text;
this.tagName = this.cbTagIdent.Text;
if (this.tagType == "")
this.tagType = "null";
this.tagIndex = map.Functions.ForMeta.FindByNameAndTagType(this.tagType, this.tagName);
if (this.tagIndex != -1)
this.identInt32 = map.MetaInfo.Ident[this.tagIndex];
else
this.identInt32 = -1;
if (this.doesHaveTagType == true)
{
if (this.tagType != "null")
{
List<char> tempList = new List<char>(0);
tempList.AddRange(this.tagType.ToCharArray(0, 4));
tempList.TrimExcess();
tempList.Reverse();
char[] tempchar = tempList.ToArray();
bw.Write(tempchar);
}
else
{
bw.Write((int)-1);
}
}
bw.Write(this.identInt32);
}
开发者ID:nolenfelten,项目名称:Blam_BSP,代码行数:32,代码来源:Ident.cs
示例17: ByteArrayToFile
public bool ByteArrayToFile(string _FileName, byte[] _ByteArray)
{
try
{
// Open file for reading
System.IO.FileStream _FileStream =
new System.IO.FileStream(_FileName, System.IO.FileMode.Create,
System.IO.FileAccess.Write);
System.IO.BinaryWriter bw = new System.IO.BinaryWriter(_FileStream);
// Writes a block of bytes to this stream using data from
// a byte array.
bw.Write(_ByteArray, 0, _ByteArray.Length);
// close file stream
bw.Close();
return true;
}
catch (Exception _Exception)
{
// Error
Console.WriteLine("Exception caught in process: {0}",
_Exception.ToString());
}
// error occured, return false
return false;
}
开发者ID:dwickeroth,项目名称:covise,代码行数:28,代码来源:ThisAddIn.cs
示例18: Save
public static void Save(string directory, string file,string ext, XCImageCollection images)
{
System.IO.BinaryWriter bw = new System.IO.BinaryWriter(System.IO.File.Create(directory+"\\"+file+ext));
foreach(XCImage tile in images)
bw.Write(tile.Bytes);
bw.Flush();
bw.Close();
}
开发者ID:pmprog,项目名称:OpenXCOM.Tools,代码行数:8,代码来源:UncompressedCollection.cs
示例19: 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();
}
开发者ID:KatekovAnton,项目名称:ResourceCollector,代码行数:8,代码来源:ParticleRenderObjectDescription.cs
示例20: ByteBuffer
public ByteBuffer(byte[] data)
{
stream = new System.IO.MemoryStream();
reader = new System.IO.BinaryReader(stream);
writer = new System.IO.BinaryWriter(stream);
writer.Write(data);
stream.Position = 0;
}
开发者ID:FabioDeMiranda,项目名称:tvheadend-api-emby,代码行数:8,代码来源:ByteBuffer.cs
注:本文中的System.IO.BinaryWriter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论