Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8436879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:18:06+00:00 2026-06-10T07:18:06+00:00

I need to save an object that I have in my program (this object

  • 0

I need to save an object that I have in my program (this object stores data) to the hard drive so i can load it next time the program starts

I have tried using serialization and xml file output but I cant seem to get this working since the data I have is not of the ‘string’ object type.

I considered using file open/put/get but MSDN recommends against this since it is much more inefficient than serialization.

Any simple load/save functions that will accomplish my goal?

Thanks in advance
Martin

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:18:08+00:00Added an answer on June 10, 2026 at 7:18 am

    I figured out that I needed to convert the object to binary data before serialization.

    For others, here are my functions

    'Imports
    Imports System.IO
    Imports System.Text
    Imports System.Collections
    Imports System.Runtime.Serialization.Formatters.Binary
    Imports System.Runtime.Serialization
    
    'Functions
    Public Function Load()
        If My.Computer.FileSystem.FileExists(mstrSaveFile) Then
            Dim fs As Stream = New FileStream(mstrSaveFile, FileMode.Open)
            Dim bf As BinaryFormatter = New BinaryFormatter()
            mstrData = CType(bf.Deserialize(fs), CType(mstrData))
            fs.Close()
        End If
        Return True
    End Function
    
    Public Function Save()
        If My.Computer.FileSystem.FileExists(mstrSaveFile) = True Then
            My.Computer.FileSystem.DeleteFile(mstrSaveFile)
        End If
        Dim fs As Stream = New FileStream(mstrSaveFile, FileMode.Create)
        Dim bf As BinaryFormatter = New BinaryFormatter()
        bf.Serialize(fs, mstrData)
        fs.Close()
        Return True
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to save to an isolated storage the total time that the user
I have a Graphics object that I've drawn on the screen and I need
Working in WPF and C#, I have a TransformedBitmap object that I either: Need
In my project, some time I have to load a object to edit them.
I need to parse string from datapicker to a DataTime object and save in
I need to save the context of the program before exiting ... I've put
I need to save some classes and data structures to a file. My first
I have an object that I'm serializing that contains a lot of doubles and
I have made a program that allows users to draw lines onto a picturebox
I have WCF service that returns an object that contains an array of bytes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.