diff --git a/CSharp/Libraries/UniversalEditor.Core/IO/Reader.cs b/CSharp/Libraries/UniversalEditor.Core/IO/Reader.cs
index 8fef0fdd..317f1246 100644
--- a/CSharp/Libraries/UniversalEditor.Core/IO/Reader.cs
+++ b/CSharp/Libraries/UniversalEditor.Core/IO/Reader.cs
@@ -1506,21 +1506,6 @@ namespace UniversalEditor.IO
return buffer2;
}
- ///
- /// Aligns the to the specified number of bytes. If the current
- /// position of the is not a multiple of the specified number of bytes,
- /// the position will be increased by the amount of bytes necessary to bring it to the
- /// aligned position.
- ///
- /// The number of bytes on which to align the .
- /// Any additional padding bytes that should be included after aligning to the specified boundary.
- public void Align(int alignTo, int extraPadding = 0)
- {
- long paddingCount = ((alignTo - (base.Accessor.Position % alignTo)) % alignTo);
- paddingCount += extraPadding;
- base.Accessor.Position += paddingCount;
- }
-
public string PeekFixedLengthString(int count)
{
return PeekFixedLengthString(count, base.Accessor.DefaultEncoding);
diff --git a/CSharp/Libraries/UniversalEditor.Core/IO/ReaderWriterBase.cs b/CSharp/Libraries/UniversalEditor.Core/IO/ReaderWriterBase.cs
index bf15593b..6920ee4e 100644
--- a/CSharp/Libraries/UniversalEditor.Core/IO/ReaderWriterBase.cs
+++ b/CSharp/Libraries/UniversalEditor.Core/IO/ReaderWriterBase.cs
@@ -85,6 +85,29 @@ namespace UniversalEditor.IO
this.mvarAccessor = accessor;
this.mvarEndianness = Endianness.LittleEndian;
this.mvarReverse = false;
- }
- }
+ }
+
+ ///
+ /// Aligns the to the specified number of bytes. If the current
+ /// position of the is not a multiple of the specified number of bytes,
+ /// the position will be increased by the amount of bytes necessary to bring it to the
+ /// aligned position.
+ ///
+ /// The number of bytes on which to align the .
+ /// Any additional padding bytes that should be included after aligning to the specified boundary.
+ public void Align(int alignTo, int extraPadding = 0)
+ {
+ long paddingCount = ((alignTo - (Accessor.Position % alignTo)) % alignTo);
+ paddingCount += extraPadding;
+
+ if (Accessor.Position == Accessor.Length)
+ {
+ Accessor.Writer.WriteBytes(new byte[paddingCount]);
+ }
+ else
+ {
+ Accessor.Position += paddingCount;
+ }
+ }
+ }
}
diff --git a/CSharp/Libraries/UniversalEditor.Core/IO/Writer.cs b/CSharp/Libraries/UniversalEditor.Core/IO/Writer.cs
index 345541ef..2c6291fc 100644
--- a/CSharp/Libraries/UniversalEditor.Core/IO/Writer.cs
+++ b/CSharp/Libraries/UniversalEditor.Core/IO/Writer.cs
@@ -845,21 +845,6 @@ namespace UniversalEditor.IO
return num;
}
- ///
- /// Aligns the to the specified number of bytes. If the current
- /// position of the is not a multiple of the specified number of bytes,
- /// the position will be increased by the amount of bytes necessary to bring it to the
- /// aligned position.
- ///
- /// The number of bytes on which to align the .
- /// Any additional padding bytes that should be included after aligning to the specified boundary.
- public void Align(int alignTo, int extraPadding = 0)
- {
- long paddingCount = ((alignTo - (base.Accessor.Position % alignTo)) % alignTo);
- paddingCount += extraPadding;
- base.Accessor.Position += paddingCount;
- }
-
public void WriteDoubleEndianInt16(short value)
{
WriteInt16(value);