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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:43:01+00:00 2026-05-26T18:43:01+00:00

I am creating a program that encrypts/hashs messages I have a list that contains

  • 0

I am creating a program that encrypts/hashs messages

I have a list that contains (date,user,encryption, message,encryptedmessage)
=> Variables.oHistorique.Liste_historique.

When I just encrypt messages then save it works fine, when I open that file the list contains all the information expected however if I open a file then re-save it (even under a new name) it’s empty, the list is empty.
I appreciate all the help i can get
Thanks

P.S
I’ve checked and the list is populated when I save but not when i open the newly saved file

//when i click open

 private void ouvrirToolStripMenuItem_Click(object sender, EventArgs e)
    {
        FileDialog location = new OpenFileDialog();
        location.Filter = "Data Files (*.dat)|*.dat";
        location.FilterIndex = 1;
        result = location.ShowDialog();

        if (result == DialogResult.OK)
        {
          dataGridView1.Rows.Clear();
          Variables.oHistorique = (CHistorique)oSerialize.DeSerializeObject(location.FileName);
          for (int i = 0; i < Variables.oHistorique.Liste_historique.ToArray().Length; i++)
          {
              dataGridView1.Rows.Add(Variables.oHistorique.Liste_historique[i].Date, Variables.oHistorique.Liste_historique[i].User, Variables.oHistorique.Liste_historique[i].Type, Variables.oHistorique.Liste_historique[i].Chaine, Variables.oHistorique.Liste_historique[i].ChaineCrypt);
          }
          dataGridView1.CurrentCell = null;  
        }
    }

//When I click on save :

private void sauvgarderToolStripMenuItem_Click(object sender, EventArgs e)
    {
        FileDialog location = new SaveFileDialog();
        location.Filter = "Data Files (*.dat)|*.dat";
        location.FilterIndex = 1; 
        result = location.ShowDialog();

        if (result == DialogResult.OK)
        {   
        oSerialize.SerializeObject(CHistorique.GetInstance(),location.FileName);
        }

    }

//Here’s my class Serialize

 class CSerialize
{

    private static CSerialize Instance;

    private CSerialize()
    {

    }

    public void SerializeObject(object o, string file)
    {
        Stream stream = File.Open(file, FileMode.Create);
        BinaryFormatter b = new BinaryFormatter();
        b.Serialize(stream, o);
        stream.Close();
    }
    public object DeSerializeObject(string file)
    {
        Object o;
        Stream stream = File.Open(file, FileMode.Open);
        BinaryFormatter b = new BinaryFormatter();
        o = b.Deserialize(stream);
        stream.Close();
        return o;
    }
    public static CSerialize GetInstance()
    {
        if (Instance == null)
        {
            Instance = new CSerialize();
        }
        return Instance;
    }
}
  • 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-26T18:43:01+00:00Added an answer on May 26, 2026 at 6:43 pm

    I found the answer
    I replaced

    oSerialize.SerializeObject(CHistorique.GetInstance(),location.FileName);
    

    with

    oSerialize.SerializeObject(Variables.oHistorique,location.FileName);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im creating a program that is supposed have the user enter a student name
I have a program that's creating a secure directory for user output. This is
I am creating a program that needs to store the user's data in encrypted
I have been tasked with creating a program that will generate an amortization schedule.
I want to make program that encrypts (later decrypts) user inputted string. Here is
I'm creating a program that parses a log file for a user's name and
OK, let's say I am creating a program that will list users contacts in
I am creating a program that allows the user to select a drive letter
I have a program that is creating multiple files. There is a function for
I am creating a program that will run an experiment on a user. It

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.