C # сериализует общий список в файл

у меня есть класс, который содержит информацию об изображениях, такую ​​как путь к файлу, хэш-значение, байты. в другом классе у меня есть общий список, в который я помещаю объекты из класса, который содержит изображение Информация.

этот класс выглядит так:

[Serializable()]
    class PicInfo : ISerializable
    {
        public string fileName { get; set; }
        public string completeFileName { get; set; }
        public string filePath { get; set; }
        public byte[] hashValue { get; set; }

        public PicInfo()
        { }

        public PicInfo(SerializationInfo info, StreamingContext ctxt)
        {
            this.fileName = (string)info.GetValue("fileName", typeof(string));
            this.completeFileName = (string)info.GetValue("completeFileName", typeof(string));
            this.filePath = (string)info.GetValue("filePath", typeof(string));
            this.hashValue = (byte[])info.GetValue("hashValue", typeof(byte[]));
        }

        public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
        {
            info.AddValue("fileName", this.fileName);
            info.AddValue("completeFileName", this.completeFileName);
            info.AddValue("filePath", this.filePath);
            info.AddValue("hashValue", this.hashValue);
        }
    }

мой список всего лишь list pi = new list (); что было бы самым простым способом сериализации этого list?

7
задан Marc Gravell 1 November 2011 в 09:09
поделиться