Click here to Skip to main content
16,018,006 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Designing a windows form application, I declared the following -

String x = "";
String[] y = new String[4];

I intend passing values to x and y to be retrievable even after exiting the program or shutting down the computer.
Please guide me on how to do this please.
Thanks.
Posted

There are plenty of things you could use to store something.

* Database (Remote)
* Serialize (Binary File, local)
* Serialize (Text File, local)


For storing something in a database you need to know sql, you need to own a database server.
There are plenty of serverprograms out there, some are: mysql, postgresql, oraclesql,...

For Serializing I can only give you some links:
Yaxlib. Xml Format, human Readable
General MS Documentation
Xml Serializer from Microsoft

Or you can write a serializer on your own.
This is a example which writes a String[] to a file and reads it again. Note you can't use '~' in the string.

C#
string[] tok = {"test", "test", "test", "test"};
...
String toFile = "";
foreach (String s in tok) {
    toFile += s + "~";
}

File.WriteAllText("myfile.txt", toFile);


and for reading this could be your solution:

C#
String text = File.ReadAllText("myfile.txt");
String[] arr = text.Split('~');
 
Share this answer
 
You need to save it in database.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900