I'm trying to get me to enter the .zip file, select a single file named mcmod.info
and save it to a MemoryStream
temp.
I followed it as this link in StackOverflow, but when I read var ms = new MemoryStream()
using a var texto = new StreamReader(ms).ReadToEnd();
and have it use MessageBox.Show(texto);
the MessageBox returns an empty String.
ZipFile zf = ZipFile.Read(@"C:\big-reactors.zip");
ZipEntry ze = zf["mcmod.info"];
MemoryStream memory_stream = new MemoryStream();
ze.Extract(memory_stream);
TextReader text_reader = new StreamReader(memory_stream);
string json = text_reader.ReadToEnd();
MessageBox.Show(json);
In the file mcmod.info
it contains type json , these lines:
[
{
"modid": "BigReactors",
"name": "Big Reactors",
"description": "Adds large, multiblock power generation machines to Minecraft. Compatible with Redstone Flux (RF) power.",
"version": "0.4.3A",
"mcversion": "1.7.10",
"url": "http://www.big-reactors.com",
"updateUrl": "",
"authorList": ["ErogenousBeef"],
"credits": "powercrystals, skyboy, King_Lemming, & Calclavia for example code",
"logoFile": "",
"screenshots": [],
"dependencies": [
"MinecraftForge", "CoFHCore"
]
}
]
I have already made a code that does the Deserialization of it, but the focus at the moment is that I have a return of Stream.ReadToEnd();
I used this to deserialize:
public class MCModInfo
{
public string modid { get; set; }
public string name { get; set; }
public string description { get; set; }
public string version { get; set; }
public string mcversion { get; set; }
public string url { get; set; }
public string updateUrl { get; set; }
public List<string> authorList { get; set; }
public string credits { get; set; }
public string logoFile { get; set; }
public List<string> screenshots { get; set; }
public string parent { get; set; }
public List<string> requiredMods { get; set; }
public List<string> dependencies { get; set; }
public List<string> dependants { get; set; }
public bool useDependencyInformation { get; set; }
}
public class MCModInfo_Parser
{
public MCModInfo Deserialize(string json)
{
return JsonConvert.DeserializeObject<MCModInfo>(json);
}
public string Serialize(MCModInfo mcmodinfo)
{
return JsonConvert.SerializeObject(mcmodinfo);
}
}