提问人:Joelminer 提问时间:10/29/2022 最后编辑:Joelminer 更新时间:10/29/2022 访问量:47
BinaryReader 返回正确的字符串,但缺少前三个字符
BinaryReader returns the correct string but misses the first three characters
问:
我编写了这段代码来从文件中读取。当它从文件中读取时,它会返回正确的字符串,但它不会保存前三个字符。该程序旨在令人满意地处理游戏中的保存文件。
using System.Diagnostics;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.Text;
namespace SatisfactorySaveParser
{
public class FSaveHeader
{
public int SaveHeaderVersion;
public int SaveVersion;
public int BuildVersion;
public string MapName;
public string MapOptions;
public string SessionName;
public int PlayedSeconds;
public long SaveTimeStamp;
public byte SessionVisibility;
public int UnrealEngineVersion;
public string ModMetadata;
public int ModFlags;
public string SaveIdentifier;
public void Parse(FileStream stream, string filename)
{
BinaryReader reader = new BinaryReader(stream, Encoding.UTF8);
int Length = filename.Length;
SaveHeaderVersion = reader.ReadInt32();
SaveVersion = reader.ReadInt32();
BuildVersion = reader.ReadInt32();
MapName = reader.ReadString();
MapOptions = reader.ReadString();
SessionName = reader.ReadString();
ModFlags = reader.ReadInt32();
PlayedSeconds = reader.ReadInt32();
SaveTimeStamp = reader.ReadInt32();
SessionVisibility = reader.ReadByte();
UnrealEngineVersion = reader.ReadInt32();
ModMetadata = reader.ReadString();
ModFlags = reader.ReadInt32();
SaveIdentifier = reader.ReadString();
}
}
}
我尝试了二进制读取器类的不同方法,以及从文件中读取的不同方法。
答: 暂无答案
评论
BinaryWriter
ReadString
FileStream