Read/Write file via Share Memory
Dear Sirs
I have a class as follows code, When a LotNum data changes, I want to save the WIPData to file immediately. The file will be load when application starting. Can I use share memory mapping to a file, after that I can access the share menory to read/write the file directly?
Best Regards,
<Serializable()> Public Class WIPData
Implements ISerializablePublic PartNum As String
Public LotNum As New List(Of String)Public Sub New()
'aMaterial_Lot_Number = New ArrayList
End Sub
Private Sub New(ByVal Info As SerializationInfo, ByVal Context As StreamingContext)
'aMaterial_Lot_Number = New ArrayList
With Info
Me.LotNum = .GetValue("LotNum", Me.LotNum.GetType)
Me.PartNum = .GetString("PartNum")
End WithEnd Sub
Public Sub GetObjectData(ByVal info As System.Runtime.Serialization.SerializationInfo, ByVal context As System.Runtime.Serialization.StreamingContext) Implements System.Runtime.Serialization.ISerializable.GetObjectData
info.AddValue("PartNum", Me.PartNum)
info.AddValue("LotNum", Me.LotNum, Me.LotNum.GetType())End Sub
End Class
Answers
- You can save that direct, by simply serialize the array direct.
Look at this sample Tom made once bassicly.
http://www.vb-tips.com/SerializeArrayList.aspx
However, for your problem is an IList implementing class like the Generic Dictionary much better.
Be aware that if you write this in this way to file, you have to read and write it constantly.
For that you can use the streamreader and streamwriter in its standard way.
Success
Cor- Marked As Answer byMartin Xie - MSFTMSFT, ModeratorMonday, November 09, 2009 3:02 AM
All Replies
- Welcome to MSDN forums!
You also can consider posting it at .NET Runtime Serialization Forum for quicker and better responses.
http://social.msdn.microsoft.com/Forums/en-US/netfxremoting/threads
Thank you for your active participation in MSDN community.
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. - You can save that direct, by simply serialize the array direct.
Look at this sample Tom made once bassicly.
http://www.vb-tips.com/SerializeArrayList.aspx
However, for your problem is an IList implementing class like the Generic Dictionary much better.
Be aware that if you write this in this way to file, you have to read and write it constantly.
For that you can use the streamreader and streamwriter in its standard way.
Success
Cor- Marked As Answer byMartin Xie - MSFTMSFT, ModeratorMonday, November 09, 2009 3:02 AM


