I dont have time to compile post for how to read media pk 2 so
You can search in the net for example: how to read media pk2 c#
Than when you understand how to read mediapk2
use this for Version
Code:
public static void GetVersion()
{
System.Threading.Thread.Sleep(500);
PK2Reader.Reader Pk2Reader;
try { Pk2Reader = new PK2Reader.Reader(MainData.Mediapk2, MainData.PK2Key); }
catch (Exception)
{
MessageBox.Show("Validsss Key");
return;
}
if (File.Exists(Environment.CurrentDirectory + @"\data\SV.T"))
{
File.Delete(Environment.CurrentDirectory + @"\data\SV.T");
}
Pk2Reader.ExtractFile("SV.T",Environment.CurrentDirectory + @"\data\SV.T");
var path = Environment.CurrentDirectory + @"\data\SV.T";
using (FileStream fs = File.OpenRead(path))
{
using (var reader = new BinaryReader(fs))
{
var versionBufferLength = reader.ReadInt32();
var versionBuffer = reader.ReadBytes(versionBufferLength);
var version = Read(versionBuffer);
MainData.Version = version;
}
}
File.Delete(Environment.CurrentDirectory + @"\data\SV.T");
Pk2Reader.Dispose();
}
public static int Read(byte[] buffer)
{
if (blowfish == null)
InitiateBlowfish();
var decodedBuffer = blowfish.Decode(buffer);
return int.Parse(Encoding.ASCII.GetString(decodedBuffer, 0, 4));
}
public static byte[] Save(int version)
{
if (blowfish == null)
InitiateBlowfish();
var buffer = Encoding.ASCII.GetBytes(Convert.ToString(version));
Array.Resize(ref buffer, 8); //adds padding to use blowfish directly on this buffer
return blowfish.Encode(buffer);
}
private static void InitiateBlowfish()
{
blowfish = new SecurityAPI.Blowfish();
blowfish.Initialize(Encoding.ASCII.GetBytes(ASCII_KEY), 0, 8);
}
if you cant find or you cant understan how to read. send private message