3 Replies - 6505 Views - Last Post: 14 January 2013 - 02:32 PM Rate Topic: -----

#1 mbcoccia  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 16-November 12

Best practice to add txt file to windows forms

Posted 14 January 2013 - 08:23 AM

Hi! I am new to C# programming and found this website a great resource for learning and growing. Currently, I am developing a windows form tracking contact information (employee ID, name, address, phone, etc) and I looking for the best practice to connect a text file to my windows form. The text file will be saved to disk after displayed on console to confirm accuracy of data entry. When addition data is entered into the form it will be appended to text file. I am looking at streamreader and streamwriter to handle this process. Am I moving in the right direction is there another resource to consider. Any advice, tutorial, article would be appreciated regarding this matter.

Thanks again for a great resource.

MB

Is This A Good Question/Topic? 0
  • +

Replies To: Best practice to add txt file to windows forms

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9573
  • View blog
  • Posts: 36,255
  • Joined: 12-June 08

Re: Best practice to add txt file to windows forms

Posted 14 January 2013 - 08:25 AM

Quote

I am looking at streamreader and streamwriter to handle this process. Am I moving in the right direction is there another resource to consider.

Yes that is the way to go.

Literally it's a three line job..
Create the writer
Write line
Close the writer.

http://msdn.microsof...reamwriter.aspx
Was This Post Helpful? 0
  • +
  • -

#3 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5676
  • View blog
  • Posts: 12,194
  • Joined: 02-June 10

Re: Best practice to add txt file to windows forms

Posted 14 January 2013 - 09:37 AM

Quote

I am developing a windows form tracking contact information (employee ID, name, address, phone, etc) and I looking for the best practice to connect a text file to my windows form.


I'm going to stop you there because all of those things don't go together.
Tracking contacts and textfile are not anything close to best practices.

At the very least you should be objectifying your contacts (a Contact class object) then serializing it to XML instead of reading text files.

But it would be FAR FAR better to use a database for this. Visual Studio will let you build a program with a database as service so you don't have to install a database engine or anything. Its all there built-in for you already.

This post has been edited by tlhIn`toq: 14 January 2013 - 09:39 AM

Was This Post Helpful? 1
  • +
  • -

#4 CasiOo  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1424
  • Posts: 3,166
  • Joined: 05-April 11

Re: Best practice to add txt file to windows forms

Posted 14 January 2013 - 02:32 PM

Quote

But it would be FAR FAR better to use a database for this. Visual Studio will let you build a program with a database as service so you don't have to install a database engine or anything. Its all there built-in for you already.


Wow for all this time, I did not know VS could do that

Awesome!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1