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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:13:26+00:00 2026-05-26T15:13:26+00:00

How to save content of ArrayList to the file? I am working with the

  • 0

How to save content of ArrayList to the file? I am working with the following code but ToString() only display a name.

Edit

Other thing I have forgotten mention. I am storing the data as encrypted. The only thing I have problem with is getting the whole content of ArrayList and pass it to encryption method.

Examples for dummies recommended.

SaveFile() method

private void SaveFile()
{
    sfdSaveFile.FileName = storedAuth.UserName;
    sfdSaveFile.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
    sfdSaveFile.RestoreDirectory = true;
    sfdSaveFile.Filter = "AES Binary Files (*.abf)|*.sbf|All files (*.*)|*.*";
    sfdSaveFile.DefaultExt = ".abf";
    sfdSaveFile.FilterIndex = 1;

    sfdSaveFile.ShowDialog();
}

Save File Dialog

private void sfdSaveToLocation_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
{
    EncryptDecrypt en = new EncryptDecrypt();
    AddEntryWindow addWindow = new AddEntryWindow
                (this, storedAuth.UserName, storedAuth.Password);


    // how to save it appropriately?
    string encrypted = en.Encrypt(addWindow.addedEntry.ToString(),
        storedAuth.UserName, storedAuth.Password);

    File.WriteAllText(sfdSaveFile.FileName, encrypted);
}
  • 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-26T15:13:26+00:00Added an answer on May 26, 2026 at 3:13 pm

    Using Serialization can be good idea this method will convert array to string (the type of array item should be serialiazable)

    public string arrayToString(System.Collections.ArrayList ar)
    {
        StringBuilder sb = new StringBuilder();
        System.Xml.XmlWriterSettings st = new System.Xml.XmlWriterSettings();
        st.OmitXmlDeclaration = true;
        st.Indent = false;
        System.Xml.XmlWriter w = System.Xml.XmlWriter.Create(sb, st);
        System.Xml.Serialization.XmlSerializer s = new System.Xml.Serialization.XmlSerializer(ar.GetType());
        s.Serialize(w, ar);
        w.Close();
        return sb.ToString();        
    }
    
    public static void SaveArraytoFile(System.Collections.ArrayList ar, string fileName)
    {
        using (System.IO.StreamWriter sw = new StreamWriter(fileName))
        {
            foreach (var item in ar)
            {
                sw.WriteLine(item);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to save text file content to different arrays? my text file content is
Internet Explorer can save its content as an MHTML file using the Save As...
I have a plist file and i want edit this file, but setObject() in
what I want: Download a webpage from a server > Save content in a
Currently I am using Canvas2Image to save the content of my HTML5 canvas. It
im having problems on how to save the content of an array in an
We have developed a Thunderbird (11) plugin that allows us to save the content
I'm writing a Chrome userscript to locally auto-save content in a CKEditor . I'm
I've a class that stores an array and save its content on __destruct() event.
Please guide in the following class what I should save in. Please remember I

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.