Results 1 to 6 of 6

Thread: Do I have to use serialization just to dump a structure to a file?

  1. #1

    Thread Starter
    Addicted Member danielkw's Avatar
    Join Date
    Mar 2000
    Location
    Sweden
    Posts
    134

    Do I have to use serialization just to dump a structure to a file?

    Do I have to use serialization just to dump a structure to a file? I hope this is not the case. I hope I can work it out like in VB6...

    VB6 example:
    VB Code:
    1. Type TEST
    2.    test1 As Long
    3.    test2 As Integer
    4. End Type
    5.  
    6. Sub Save
    7.     Dim a As TEST
    8.     Open "C:\test.bin" For Binary Access Write As 1
    9.         Put #1, a
    10.     Close 1
    11. End Sub

    is there a way to do exatcly the same thing in VB.NET WITHOUT using serialization?

    btw, I know how to use serialization so please don't give me any examples on that...

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    I don't know of another way.

    What is the problem with serialization anyway?

  3. #3

    Thread Starter
    Addicted Member danielkw's Avatar
    Join Date
    Mar 2000
    Location
    Sweden
    Posts
    134
    there must be some way to be able to just drop a structure to a file.


    the problem with serialization is that i don't have the control. i can't decide where to put the information and a lot of unnessecary information is also being stored.

    when using vb6 i can put a structure wherever i want in a file. maybe there is a way to do that using serialization, i don't know.

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You can implement ISerializable in your object to have more control over the serialization process. Its funny that you don't like serialization considering its less code and easier to work with. Alternatively there may be some methods of file access like you want in the Visual Basic Compatiblity namespaces or IO namespace.

  5. #5

    Thread Starter
    Addicted Member danielkw's Avatar
    Join Date
    Mar 2000
    Location
    Sweden
    Posts
    134
    it's not that i don't like serialization because i do. it's just that now it didn't 100% fit my needs.

    can you give me an example of implementing the ISerializable and using it.

    thanks.

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Originally posted by danielkw
    it's not that i don't like serialization because i do. it's just that now it didn't 100% fit my needs.

    can you give me an example of implementing the ISerializable and using it.

    thanks.
    I cannot, I haven't tried implementing it before but there shoudl be an example in the help files.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width