aferia
asked on
How can I assign "Me" reference from a class to a value?
I am trying to write a LoadFromFile() Sub that will deserialize a file from the HD into my class object, but I cant do it because " 'Me' cannot be target of an assignment ". Right now I am deserializing into a temporary object and then assigning member by memebr to the Me instance. Is thera a way around this?
Dim formatter As System.Runtime.Serialization.Formatters.Binary.BinaryFormatter = New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter()
Dim output As FileStream
Dim fileName As String = file.FullName
Try
output = New FileStream(fileName, FileMode.Open, FileAccess.Read)
Dim tempCon As CConnectionData.CSettings
tempCon = formatter.Deserialize(output)
Me.m_szDatabase = tempCon.m_szDatabase
Me.m_szLoginName = tempCon.m_szLoginName
Me.m_szPassword = tempCon.m_szPassword
Me.m_szSQLServer = tempCon.m_szSQLServer
Me.m_nAuthenticationType = tempCon.m_nAuthenticationType
output.Flush()
output.Close()
Catch ex As System.Runtime.Serialization.SerializationException
Console.WriteLine("Error Reading from File. " & ex.Message)
End Try
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.