| | |
how to load/save this?
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2008
Posts: 47
Reputation:
Solved Threads: 0
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!
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!
•
•
Join Date: Jul 2009
Posts: 962
Reputation:
Solved Threads: 204
If the storage file does not need to be text, check out this IO Class:
In addition, consider using the
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...
BinaryReader & BinaryWriter , which will simplify much of the data typing IO of your fields.In addition, consider using the
BinaryFormatter class: C# Syntax (Toggle Plain Text)
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.
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Make love, no war. Cave ab homine unius libri.
Danny
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. ![]() |
Similar Threads
- Loading a structure (text lines) from a file, modify the structure, then save (C)
- help in save/load database (VB.NET)
- file save load problems (C++)
- Help on dedicated network drive please. (Networking Hardware Configuration)
- Gliven, I need an idea for a program... help anyone? (Pascal and Delphi)
- reading and saving data to textfiles... (Visual Basic 4 / 5 / 6)
- Saving and opeing a JTable (Java)
- Where does Address Book & email hide? (Web Browsers)
Other Threads in the C# Forum
- Previous Thread: Background dynamic gradient
- Next Thread: Choosing the Right Integer
| Thread Tools | Search this Thread |
Tag cloud for load, save, stream
.net audio auto box browserproblems button c# c++ cache cisco click default dialog download explorer file hacker internetexplorer8 load location memory microsoft mozilla mysql nortel offline program ram recourse save security server speed stream textbox time url vb vb.net video voipshield vulnerability web windows xp







