Answer the question
In order to leave comments, you need to log in
Glitch in C#, when serializing an object, you need to serialize the Form?! What to do?
There is a procedure for "saving" an object
public void Save(Dictionary<string, FileStateInfo> data, string file)
{
//Сохраняем резервную копию
BinaryFormatter bf = new BinaryFormatter();
//откроем поток для записи в файл
using (FileStream fs = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
using (GZipStream gz = new GZipStream(fs, CompressionMode.Compress, false))
{
bf.Serialize(gz, data);//сериализация
}
}
[Serializable]
public class FileStateInfo
{
int chunksize = 500000;
public string path;
public string shortpath;
public long len;
public int chunkcount;
public Dictionary<int, Chunk> chunks = new Dictionary<int, Chunk>();
}
Answer the question
In order to leave comments, you need to log in
In general, I figured it out, there were still delegates in the class, and if a form is subscribed to them, then the ball wants to serialize it along with the object.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question