Hi all!

Well, the name isn't entirely accurate but since I have found it very hard to find some actual useful information on the topic I decided to name it as such.

Purely as a programming practice I would like to make a calendar application. Something along the lines of Rainlendar (brilliant piece of software).

It should save all my appointments and notes and ToDo things and what not.
But for that to work...

I need to be able to write all the information to my harddrive and load it again when the program is loaded again. Now I know the basics of FileStream, StreamWrite and StreamRead but I don't know how to use that with this kind of information.

I'm thinking of something along the lines of this for the lines in a simple .txt file (every type of file is fine by me by the way):
22-09-09, 12.30-14.00, Driving lessons, yes, 22-09-09, 11.00
The date of the appointment, the time, the text to display, whether and alarm should be activated, and then the date and time of that alarm.

But I don't have a clue how to implement something like this.

Is there anybody willing to hand me some pointers on this? It would really be greatly appreciated!

If the storage file does not need to be text, check out this IO Class: BinaryReader & BinaryWriter , which will simplify much of the data typing IO of your fields.

In addition, consider using the BinaryFormatter class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;

namespace TestSerializer
{
    public class DataSerializer
    {
        [Serializable]
        public class Data : ArrayList
        {
            [Serializable]
            public struct Field
            {
                string s1;
                string s2;
                string s3;
                int i1;
                int i2;
                int i3;

                public Field(string s1, string s2, string s3, int i1, int i2, int i3)
                {
                    this.s1 = s1;
                    this.s2 = s2;
                    this.s3 = s3;
                    this.i1 = i1;
                    this.i2 = i2;
                    this.i3 = i3;
                }
            }

            public Data()
            {
                for (int i = 0; i < 100000; i++)
                {
                    Field fld = new Field(
                        "1 - Some Text " + i,
                        "2 - Some Text " + i,
                        "3 - Some Text " + i,
                        i * 1,
                        i * 2,
                        i * 3
                    );

                    Add(fld);
                }
            }
        }

        public DataSerializer()
        {
            Data data = new Data();

            BinaryFormatter bf = new BinaryFormatter();
            using (Stream stream = new FileStream("data.dat", FileMode.Create, FileAccess.Write))
            {
                bf.Serialize(stream, data);
                stream.Flush();
                stream.Close();
            }

            Data dataRead;
            using (Stream stream = new FileStream("data.dat", FileMode.Open, FileAccess.Read))
            {
                dataRead = (Data)bf.Deserialize(stream);
                stream.Flush();
                stream.Close();
            }
        }

        public static void Test()
        {
            DateTime dt = DateTime.Now;
            TimeSpan dtStart = dt.TimeOfDay;

            DataSerializer ds = new DataSerializer();

            dt = DateTime.Now;
            TimeSpan dtEnd = dt.TimeOfDay;

            TimeSpan dtTotal = dtEnd - dtStart;

            Console.WriteLine("DataSerializer Total Time: " + dtTotal);
        }

    }
}

Also, check out this thread using a DataSet with xml read/write: http://www.daniweb.com/forums/thread224213.html

There are so many ways you can do this--these are but a few...

The date of the appointment, the time, the text to display, whether and alarm should be activated, and then the date and time of that alarm.

First, you should try to organize your info into a class or struct.

Once you have followed danny's recommendation and organized your members in to a class/struct you can use the XmlSerializer also to persist your class to disk.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.