I have a dictionary like the follow:
public Dictionary<int, SpawnList> spawnEntities = new Dictionary<int, SpawnList>();
The class being used is as follow:
public class SpawnList
{
public int NpcID { get; set; }
public string Name { get; set; }
public int Level { get; set; }
public int TitleID { get; set; }
public int StaticID { get; set; }
public entityType Status { get; set; }
public int TypeA { get; set; }
public int TypeB { get; set; }
public int TypeC { get; set; }
public int ZoneID { get; set; }
public int Heading { get; set; }
public float PosX { get; set; }
public float PosY { get; set; }
public float PosZ { get; set; }
}
/// <summary>Entity type enum.</summary>
public enum entityType
{
Ally,
Enemy,
SummonPet,
NPC,
Object,
Monster,
Gatherable,
Unknown
}
-
How could I save this Dictionary to
either a binary or encrypted format
so I could later Load it again into
my application ?My biggest problem here is not on how to save the file it self or encrypt it but mostly on how to do it when you have a class with it and how you go about deserializing it later.
My limitation is .Net 3.5 can’t use anything higher.
The easy way to get you started:
[Serializable]attribute.CryptoStreamandBinaryFormatterto serialize it into a file and encrypt the data.The reference for
CryptoStreamprovides a complete example for setting up encryption and doing the related file handling.