private void button1_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); if (openFileDialog.ShowDialog() == DialogResult.OK) { perceptron = LoadFile(openFileDialog.FileName); if (LoadFile(openFileDialog.FileName) == null) { MessageBox.Show("f**k"); } } }
public Backpropagation.Perceptron LoadFile(string fileName) { FileStream fileStream = null; Backpropagation.Perceptron p = null; try { fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); BinaryFormatter deserializer = new BinaryFormatter(); p = (Backpropagation.Perceptron)deserializer.Deserialize(fileStream); } catch (Exception e) { Console.WriteLine("There's been an error. Here is the message: " + e.Message); } finally { if (fileStream != null) { fileStream.Close(); } } return(p); }