I've been searching for 2 hours or better for a way to use the Read7BitEncodedInt method for this. I need to use it somehow to reduce my file size (in this case likely by 100mb or more). I was also looking at using the ReadString method since it seems to do roughly the same thing. But that seems less appropriate and I'm not really sure that it would work. If there is some other alternative to this that I'm unaware of I'd be open to using that too.
In summation. How would I implement the Read7BitEncodedInt method into the following code ? Also, I'm not too certain that my method to Write7BitEncodedInt is correct either.
public void SaveFile()
{
using (FileStream stream = new FileStream("C:\\A_random.txt", FileMode.Create))
{
using (BinaryWriter writer = new BinaryWriter(stream))
{
for (int i = 0; i < typeCount.Count; i++)
{
writer.Write((byte)typeCount[i]);
writer.Write(type[i]);
}
writer.Close();
}
}
LoadFile();
}
public void LoadFile()
{
using (FileStream stream = new FileStream("C:\\A_random.txt", FileMode.Open))
{
using (BinaryReader reader = new BinaryReader(stream))
{
int i = 0;
while (stream.Position != stream.Length)
{
int count = reader.Read7BitEncodedInt();
byte val = reader.ReadByte();
for (int ii = 0; ii < count; ii++)
{
grid[i].val1 = i;
grid[i].val2 = val;
grid[i].val3 = vect;
i++;
}
}
reader.Close();
}
}
}