Write a value at a given position. Used to write a size of data in an earlier located header.
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.IO;
namespace Vestris.ResourceLib
{
/// <summary>
/// Resource utilities.
/// </summary>
public abstract class ResourceUtil
{
/// <summary>
/// Write a value at a given position.
/// Used to write a size of data in an earlier located header.
/// </summary>
/// <param name="w">Binary stream.</param>
/// <param name="value">Value to write.</param>
/// <param name="address">Address to write the value at.</param>
internal static void WriteAt(BinaryWriter w, long value, long address)
{
long cur = w.BaseStream.Position;
w.Seek((int) address, SeekOrigin.Begin);
w.Write((UInt16) value);
w.Seek((int) cur, SeekOrigin.Begin);
}
}
}
Related examples in the same category