Original Post
Hi everyone! I'm working on a SaveLoading feature for a program, and a friend recommended me to come here and ask about it. I coded the SaveFile feature already, which seems to be working just fine. Allow me to explain: I have a MDIForm with this simple code for the Save button: Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click GuardarArchivo() End Sub So, no mystery there. I will work on the SavingDialog sometime in the future. GuardarArchivo() is a Sub I created in a different Module, which does the saving using a BinaryFormatter. I'm using that because it's the easiest one to use and because I don't really care about being able to see the contents of the saved file. The code is as follows: Public Sub GuardarArchivo() Dim BinaryFormatter As New Runtime.Serialization.Formatters.Binary.BinaryFormatter() Dim MemoryStream As New IO.MemoryStream Dim GuardarClassAbrirGuardar As New ClassAbrirGuardar GuardarClassAbrirGuardar.GuardarTextBox1 = FormInicio.TextBox1.Text GuardarClassAbrirGuardar.GuardarTextBox2 = FormInicio.TextBox2.Text GuardarClassAbrirGuardar.GuardarTextBox3 = FormInicio.TextBox3.Text BinaryFormatter.Serialize(MemoryStream, GuardarClassAbrirGuardar) My.Computer.FileSystem.WriteAllText("C:\Test.txt", Convert.ToBase64String(MemoryStream.ToArray()), False) End Sub ClassAbrirGuardar is a serializable Class where I'm creating the variables: Public Class ClassAbrirGuardar Public GuardarTextBoxTítulo As String Public GuardarTextBoxPrint As String Public GuardarTextBoxPlot As String End Class So, alright, everything works here. I'm creating my Text.txt with a lot of serialized glibberish. Now the problem is... How to get it back again? I read somewhere about using something like this: Private Function Load() Dim FilIndhold As String = My.Computer.FileSystem.ReadAllText("C:\Test.txt") Dim BinaryFormatter As New Runtime.Serialization.Formatters.Binary.BinaryFormatter() Dim MemoryStream As New IO.MemoryStream(Convert.FromBase64String(FilIndhold)) Return (DirectCast(BinaryFormatter.Deserialize(MemoryStream), ClassAbrirGuardar)) End Function However, I'm getting nothing. How can I load everything back to where it was from a saved file? Any clues?