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 6955767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:46:51+00:00 2026-05-27T14:46:51+00:00

I need to persist a list of object between application launches per user basis;

  • 0

I need to persist a list of object between application launches per user basis; how can I do it?

The object is simple: 4 strings and one int.

  • 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-05-27T14:46:52+00:00Added an answer on May 27, 2026 at 2:46 pm

    Description

    One way is to use BinaryFormatter to save a list of serializable objects to a binary file. You can use the SoapFormatter if you want a readable / editable file.

    Sample

    Here a class that makes it possible to save a list of serializable objects.

    [Serializable]
    public class BinareObjectList<T> : List<T>
    {
        public void LoadFromFile(string fileName)
        {
            if (!File.Exists(fileName))
                throw new FileNotFoundException("File not found", fileName);
    
            this.Clear();
    
            try
            {
                IFormatter formatter = new BinaryFormatter();
                // IFormatter formatter = new SoapFormatter();
                Stream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
                List<T> list = (List<T>)formatter.Deserialize(stream);
                foreach (T o in list)
                    this.Add(o);
                stream.Close();
            }
            catch { }
        }
    
        public void SaveToFile(string fileName)
        {
            if (File.Exists(fileName))
                File.Delete(fileName);
    
            IFormatter formatter = new BinaryFormatter();
            // IFormatter formatter = new SoapFormatter();
            Stream stream = new FileStream(fileName, FileMode.CreateNew);
            formatter.Serialize(stream, this);
            stream.Close();
        }
    }
    

    More Information:

    • MSDN: BinaryFormatter Class
    • MSDN: SoapFormatter Class

    Update

    You said in a comment that you try to save application settings. Consider using Application Settings.

    MSDN: Using Settings in C#

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose, as part of an iphone application, I need to show user a list
I need to persist an object that is not marked with the serializable attribute.
I have an app where I need a BOOL value to persist across launches.
Short Version I have a list of int s that I need to figure
I have a simple entity, Code, that I need to persist to a MySQL
I have MVC3 web application where we need to populate radio button list with
In my application, users have a list of items that they can put in
I have an array of bytes in my C# class, and need to persist
How to handle/persists columns reorder? Don't need to change it. Need to persist it
I have the following setup, and I need to know how to persist state.

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.