The ProgrammersTalk Community
Forum Register Search Today's Posts Mark Forums Read
Register

Go Back   The ProgrammersTalk Community > General Programming > C#


Welcome to the The ProgrammersTalk Community forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.
Reply
 
LinkBack Thread Tools    Display Modes   
  #1 (permalink)  
Old 08-03-2007, 03:23 PM
TeraTask's Avatar
TeraTask TeraTask is offline
PT Staff*
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 3
Join Date: Jun 2007
Location: Reno, NV
Posts: 428
iTrader: (0)
TeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enough
File Format

This doesn't necessarily have to go in the C# area, but that's the lang I'll be using. I'm getting ready to code an application which will require the saving of data. Now, I could create my own custom format, create a database using SQL (not what I want to do at all!), use XML, or use an already existing format (e.g. csv, tab-delimited, etc.) What do you use for saving data in a desktop application? Is there some standard that people use?

__________________
Jeremy Miller
Content Farmer - Optimized Automated Blog Posting

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #2 (permalink)  
Old 08-03-2007, 03:44 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,111
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
Here's the byte writer for C#:

PHP Code:
System.IO.FileStream fs System.IO.File.Create("filename"1024// 1024 is the byte limit 
Hopefully that helps!
I'm pretty sure that C# also has another type of writer that will let you write it line by line. You'd probably want to double check on that...

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
The Following User Says Thank You to HelloWorld For This Useful Post:
TeraTask (08-03-2007)
  #3 (permalink)  
Old 08-03-2007, 03:47 PM
TeraTask's Avatar
TeraTask TeraTask is offline
PT Staff*
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 3
Join Date: Jun 2007
Location: Reno, NV
Posts: 428
iTrader: (0)
TeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enough
Thanks. What I meant, though, was what format do you choose to store it in?

For example, if I were collecting website, username, and password, then I could store it like

Code:
website1,username1,password1
website2,username2,password2
website3,username3,password3
or

Code:
<site>
  <url>website1</url>
  <username>username1</username>
  <password>password1</password>
</site>
<site>
  <url>website2</url>
  <username>username2</username>
  <password>password2</password>
</site>
<site>
  <url>website3</url>
  <username>username3</username>
  <password>password3</password>
</site>
or any other number of ways. Which do most of you store your data in for ease of access via C#?

Does that make more sense?

__________________
Jeremy Miller
Content Farmer - Optimized Automated Blog Posting

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #4 (permalink)  
Old 08-03-2007, 03:54 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,111
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
I'd personally like the first one better:

Code:
website1,username1,password1
website2,username2,password2
website3,username3,password3
It's much easier to do data retrieval from this kind of file because you can always "tokenize" it at "," lol... (sorry, I always mentioned tokenizer on several of my posts. Tokenizer is one of my most favorite class.)

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
The Following User Says Thank You to HelloWorld For This Useful Post:
TeraTask (08-03-2007)
  #5 (permalink)  
Old 08-03-2007, 04:02 PM
rpgfan3233 rpgfan3233 is offline
PT Staff
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 4
Join Date: Jul 2007
Posts: 118
iTrader: (0)
rpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura aboutrpgfan3233 has a spectacular aura about
XML is common, and INI files are still used too. Honestly, it doesn't matter which one you use since they're both text. If the language has a specific facility for reading and parsing XML, it may be faster than using an INI file, though a language may also have built-in support for reading and parsing an INI file too. You could also use a binary file format, where the lengths of the "records" are varied in length. For example, you could have the equivalent of the following to store usernames (thinking about it like a hex editor):
'd' 'u' 'm' 'm' 'y' 00
'F' 's' 't' 00

You could also store the length, eliminating the need to check for a null terminator and also allowing you to have more control because you would not be reading an unknown number of bytes until you hit a null terminator, which may in fact be absent if improperly coded. The downside to this method is that you would need to ensure that it is saved properly, which would most likely require a hex editor if you don't have one already.

__________________
"C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off."
-- Bjarne Stroustrup, creator of what is now known as C++
For more quotes by Bjarne Stroustrup, check out http://www.research.att.com/~bs/bs_faq.html#really-say-that.
Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
The Following 2 Users Say Thank You to rpgfan3233 For This Useful Post:
HelloWorld (08-03-2007), TeraTask (08-03-2007)
  #6 (permalink)  
Old 08-03-2007, 04:10 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,111
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
Quote:
XML is common, and INI files are still used too. Honestly, it doesn't matter which one you use since they're both text. If the language has a specific facility for reading and parsing XML, it may be faster than using an INI file, though a language may also have built-in support for reading and parsing an INI file too.
I haven't used any XML reader before lol.. that's why I still prefer to read it by ASCII.. but I think I should try that out I think Java has XML parser or something like that. I can pretty much assume that C# also has it since they're both really similar.

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #7 (permalink)  
Old 08-03-2007, 04:32 PM
TeraTask's Avatar
TeraTask TeraTask is offline
PT Staff*
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 3
Join Date: Jun 2007
Location: Reno, NV
Posts: 428
iTrader: (0)
TeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enough
XML bothers me b/c it takes up so much space and offers little in return for data that doesn't need to be transferred between various applications while complicating the parsing of the data substantially. I think I'll go ahead and stick with a csv-like format, but stored in binary. I don't know much about the .ini file format.

Thanks for all the tips and feedback - very much appreciated!

__________________
Jeremy Miller
Content Farmer - Optimized Automated Blog Posting

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #8 (permalink)  
Old 08-03-2007, 04:44 PM
Lee's Avatar
Lee Lee is offline
PT Staff*
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: Blackpool, UK
Posts: 616
iTrader: (0)
Lee will become famous soon enoughLee will become famous soon enoughLee will become famous soon enoughLee will become famous soon enough
I like using XML the most, i have used it a couple of times now, once you start getting your head round parsing it in your language of choice then you see its not really that hard to save, delete, create etc...

XML is also good if you want the user to be able to change the settings from that file, lets say there's an error in the application on load in a version where your error handling is not 100%, they can just change a setting in the XML file to make it all work again, rather than a reinstall or something like that.

Another good example is when you have different languages and the user is computer literate (Or has a user guide) and would like to change something in there language, say you have a button with the text "Exit" from the XML file, the user could change it to "Close" or something like that, which can be good as users like it when things are the way they want.
Reply With Quote
The Following 2 Users Say Thank You to Lee For This Useful Post:
HelloWorld (08-03-2007), TeraTask (08-03-2007)
  #9 (permalink)  
Old 08-03-2007, 04:50 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,111
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
I personally never have used XML in my lifetime, but I've just seen it. I probably should try the use of XML sometimes lol... I just seen it's being used as the feeder, that's all haha... *plus whatever you told me before about changing language*

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #10 (permalink)  
Old 08-03-2007, 04:52 PM
TeraTask's Avatar
TeraTask TeraTask is offline
PT Staff*
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 3
Join Date: Jun 2007
Location: Reno, NV
Posts: 428
iTrader: (0)
TeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enough
It's a fairly simple construct, actually. My second example above is in XML (minus the header declaration). The example above is fairly easy to parse using regular expressions. It gets complicated when you have recursive nesting.

__________________
Jeremy Miller
Content Farmer - Optimized Automated Blog Posting

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

   Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 11:55 AM. Powered by vBulletin
Copyright © 2000 - 2007, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO © 2007 ProgrammersTalk Sedo - Buy and Sell Domain Names and Websites project info: programmerstalk.net Statistics for project programmerstalk.net etracker® web controlling instead of log file analysis


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50