Generisches, komprimiertes, deserialisieren von Objekten
public static T Load<T>(string path) {
if(path != null && File.Exists(path)) {
using(FileStream fs = new FileStream(path, FileMode.Open)) {
using(GZipStream zip = new GZipStream(fs, CompressionMode.Decompress)) {
BinaryFormatter bf = new BinaryFormatter();
return (T)bf.Deserialize(zip);
}
}
}
return default(T);
}
Kommentare zum Snippet