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);
}
Using Serialization can be good idea this method will convert array to string (the type of array item should be serialiazable)