Search code examples
c#arrayslistboxsaving-data

c# How do I save an array without a savefile


I have an array of randomized music files. Is there a way to save an array in my .exe without creating a save file?

This is my array string[] playlist = new string[] { };

It is created under public partial class frmMain : Form when the program starts up.

I tried looking over How do I save an array of objects in a C# ASP.Net Sesssion? but i don't understand anything there.


Solution

  • Ok m8 it seems there is no way to save something in an .exe so I suggest you save your array to a .txt file.

    To save:

    'string[] playlist = { }; System.IO.File.WriteAllLines("c:\save file.txt", playlist);'

    To open:

    string[] playlist = System.IO.File.ReadAllLines("I://LDSS Mix.txt"); for (int i = 0; i < playlist.Length; i++) { listBox1.Items.Add(playlist[i]); }